<% //******************************************************************** // define constants //******************************************************************** define("intDB", "1"); define("cart_startsize", "10"); define("cart_enlargesize", "10"); define("cart_iCount", "4"); define("cart_i_ProductID", "1"); define("cart_i_Quantity", "2"); define("cart_i_Price", "3"); define("cart_i_TaxRate", "4"); define("product_iCount", "10"); define("product_i_ProductID", "1"); define("product_i_Name", "2"); define("product_i_Code", "3"); define("product_i_CategoryID", "5"); define("product_i_ShortDescription", "6"); define("product_i_FullDescription", "7"); define("product_i_Image", "8"); define("product_i_SmallImage", "9"); define("product_i_Variants", "10"); define("customer_iCount", "25"); define("customer_i_LastName", "1"); define("customer_i_FirstName", "2"); define("customer_i_Street", "3"); define("customer_i_ZIPCode", "4"); define("customer_i_Town", "5"); define("customer_i_ShpLastName", "6"); define("customer_i_ShpFirstName", "7"); define("customer_i_ShpStreet", "8"); define("customer_i_ShpZIPCode", "9"); define("customer_i_ShpTown", "10"); define("customer_i_CustomerID", "11"); define("customer_i_Email", "12"); define("customer_i_Phone", "13"); define("customer_i_Password", "14"); define("customer_i_TitleID", "15"); define("customer_i_Cookies", "16"); define("customer_i_ShpTitleID", "17"); define("customer_i_Phrase", "18"); define("customer_i_Title", "19"); define("customer_i_ShpTitle", "20"); define("customer_i_CountryID", "21"); define("customer_i_ShpCountryID", "22"); define("customer_i_CustomerDB", "23"); define("customer_i_ShpStateID", "24"); define("customer_i_StateID", "25"); # $strImagePath = "http://www.buecherquelle.at/shop/pictures/"; $strImagePath = "pictures/"; //******************************************************************** // Gets record set of product with id ProductID //******************************************************************** function GetProductInfo( $ProductID ) { $Product = array(); $sql = "SELECT Variants, Name, Code, CategoryID, ShortDescription, Image, SmallImage, FullDescription FROM Products WHERE ProductID=" . $ProductID; $rs = mysql_query( $sql ); if( !$row = mysql_fetch_array( $rs )) { dep( "Fatal error: Product with id " . ProductID . "does not exist! (GetProductInfo,All_Inc.php)" ); } else { $Product[ product_i_ProductID ] = $ProductID; $Product[ product_i_Name ] = $row[ "Name" ]; // ff2: fields are not always set in the database if (!isset($row[ "Code" ])) $row[ "Code" ]=''; if (!isset($row[ "Variants" ])) $row[ "Variants" ] = ''; if (!isset($row[ "ShortDescription" ])) $row[ "ShortDescription" ]=''; if (!isset($row[ "Image" ])) $row[ "Image" ]=''; if (!isset($row[ "SmallImage" ])) $row[ "SmallImage" ]=''; if (!isset($row[ "FullDescription" ])) $row[ "FullDescription" ]=''; $Product[ product_i_Code ] = $row[ "Code" ]; $Product[ product_i_CategoryID ] = $row[ "CategoryID" ]; $Product[ product_i_ShortDescription ] = $row[ "ShortDescription" ]; $Product[ product_i_Image ] = $row[ "Image" ]; $Product[ product_i_SmallImage ] = $row[ "SmallImage" ]; $Product[ product_i_FullDescription ] = $row[ "FullDescription" ]; $Product[ product_i_Variants ] = $row[ "Variants" ]; } mysql_free_result( $rs ); return( $Product ); } //******************************************************************** // Customer related functions //******************************************************************** function GetCustomerInfo( $Code ) { $Customer = array(); $sql = "SELECT * FROM Customers WHERE Code='" . $Code . "'"; $rs = mysql_query( $sql ); $row = mysql_fetch_array( $rs ); $Customer[ customer_i_FirstName ] = $row[ "FirstName" ]; $Customer[ customer_i_LastName ] = $row[ "LastName" ]; $Customer[ customer_i_Street ] = $row[ "Street" ]; $Customer[ customer_i_Town ] = $row[ "Town" ]; $Customer[ customer_i_ZIPCode ] = $row[ "ZIPCode" ]; $Customer[ customer_i_ShpFirstName ] = $row[ "ShpFirstName" ]; $Customer[ customer_i_ShpLastName ] = $row[ "ShpLastName" ]; $Customer[ customer_i_ShpStreet ] = $row[ "ShpStreet" ]; $Customer[ customer_i_ShpTown ] = $row[ "ShpTown" ]; $Customer[ customer_i_ShpZIPCode ] = $row[ "ShpZIPCode" ]; $Customer[ customer_i_CustomerID ] = $row[ "CustomerID" ]; $Customer[ customer_i_CustomerDB ] = $row[ "CustomerDB" ]; $Customer[ customer_i_Phone ] = $row[ "Phone" ]; $Customer[ customer_i_Email ] = $row[ "Email" ]; $Customer[ customer_i_Password ] = $row[ "Password" ]; $Customer[ customer_i_TitleID ] = $row[ "TitleID" ]; $Customer[ customer_i_Cookies ] = $row[ "Cookies" ]; $Customer[ customer_i_ShpTitleID ] = $row[ "ShpTitleID" ]; $Customer[ customer_i_Phrase ] = $row[ "PasswordQuestion" ]; $Customer[ customer_i_CountryID ] = $row[ "CountryID" ]; $Customer[ customer_i_ShpCountryID ] = $row[ "ShpCountryID" ]; // ff2: fields do not always exist in the database if (!isset($row[ "StateID" ])) $row[ "StateID" ] = ''; if (!isset($row[ "ShpStateID" ])) $row[ "ShpStateID" ] = ''; $Customer[ customer_i_StateID ] = $row[ "StateID" ]; $Customer[ customer_i_ShpStateID ] = $row[ "ShpStateID" ]; mysql_free_result( $rs ); $Customer[ customer_i_Title ] = GetTitleFromTitleId( $Customer[ customer_i_TitleID ]); $Customer[ customer_i_ShpTitle ] = GetTitleFromTitleId( $Customer[ customer_i_ShpTitleID ]); return( $Customer ); } function GetTitleFromTitleId( $TitleId ) { $rsTitleId = mysql_query( "SELECT Title FROM Titles WHERE TitleID=" . $TitleId); if( $row = mysql_fetch_array( $rsTitleId )) { $GetTitleFromTitleId = $row[ "Title" ]; } else { $GetTitleFromTitleId = "Unknown"; } mysql_free_result( $rsTitleId); return( $GetTitleFromTitleId ); } function GenerateCustomerCategoriesString() { global $Session; //BEG MYSQL $sql_cc = "SELECT Customers.Code, CustomerCategoriesAndCustomers.CategoryID " . "FROM Customers " . "LEFT JOIN CustomerCategoriesAndCustomers ON (Customers.CustomerID = CustomerCategoriesAndCustomers.CustomerID) AND (Customers.CustomerDB = CustomerCategoriesAndCustomers.CustomerDB) " . "WHERE CustomerCategoriesAndCustomers.DeleteStatus=0 AND (((Customers.Code)='" . $Session[ "Code" ] . "'))"; //END MYSQL $rs_cc = mysql_query( $sql_cc ); if( !$row = mysql_fetch_array( $rs_cc)) { $Session[ "strCustomerCategories" ] = "((Promotions.CategoryID) is Null) "; } else { $temps = "(Promotions.CategoryID in (" . $row[ "CategoryID" ]; $row = mysql_fetch_array( $rs_cc ); while( $row ) { $temps = $temps . "," . $row[ "CategoryID" ]; $row = mysql_fetch_array( $rs_cc );; } $Session[ "strCustomerCategories" ] = $temps . ") or ((Promotions.CategoryID) Is Null)) "; } mysql_free_result( $rs_cc ); } //******************************************************************** // Currency related functions //******************************************************************** function GetNetto( $price, $tax ) { return $price * 100 / ($tax+100); } function GetCurrencyStr( $value ) { global $Session; return( GetCurrencyStrWithCurrency( $value, $Session[ "strCurrencySymbol" ])); } function GetCurrencyStrWithCurrency( $value, $strCurrencySymbol ) { // round number to 2 decimal places $intFraction = round( $value * 100- floor( $value ) * 100 + 0.00001 ); $value = floor( $value ); while ($intFraction >= 100) { $intFraction = $intFraction - 100; $value = $value + 1; } if( $intFraction == 0 ) $res = $value . ",-" . " " . WebEncode($strCurrencySymbol); elseif( $intFraction < 10 ) $res = $value . ",0" . $intFraction . " " . WebEncode($strCurrencySymbol); else $res = $value . "," . $intFraction . " " . WebEncode($strCurrencySymbol); return $res; } function GetCurrencyStrWithCurrencyUS( $value, $strCurrencySymbol ) { // round number to 2 decimal places $intFraction = round( $value * 100- floor( $value ) * 100 + 0.00001 ); $value = floor( $value ); if( $intFraction < 10 ) $res = WebEncode($strCurrencySymbol) . " " . $value . ".0" . $intFraction; else $res = WebEncode($strCurrencySymbol) . " " . $value . "." . $intFraction; return $res; } //******************************************************************** // Paymentmode related functions //******************************************************************** function ConvertPaymentModeName( $str, $strIDString ) { if( strcmp( $strIDString, "CreditCard" ) == 0 ) { if( is_int( strpos( $str, "(" ))) { return( substr( $str, 0, strpos( $str, "(" ))); } else { return( $str ); } } else { return( $str ); } } function GetCurrentPaymentInfoDebitEntry() { global $Session; return "DebitEntry:" .$Session[ "DebitEntryName"] . ":" .$Session[ "DebitEntryCode"] . ":" .$Session[ "DebitEntryAccount"]; } function GetCurrentPaymentInfoCreditCard() { global $Session; return "CreditCard:" .$Session[ "CreditCardType"] . ":" .$Session[ "CreditCardOwner"] . ":" .$Session[ "CreditCardNumber"] . ":" .$Session[ "CreditCardExpirationMonth"] . ":" .$Session[ "CreditCardExpirationYear"]; } function GetCurrentPaymentInfo() { global $Session; if( 0 == strcmp( $Session[ "strPaymentModeIDString" ], "CreditCard" )) { return GetCurrentPaymentInfoCreditCard(); } elseif( 0 == strcmp( $Session[ "strPaymentModeIDString" ], "DebitEntry" )) { return GetCurrentPaymentInfoDebitEntry(); } return ""; } function GetPaymentModeIDString( $lngID ) { $rsGetPaymentModeIDString = mysql_query( "SELECT IDString FROM PaymentModes WHERE PaymentModeID=" . $lngID ); if( $row = mysql_fetch_array( $rsGetPaymentModeIDString )) $GetPaymentModeIDString = $row[ "IDString" ]; else $GetPaymentModeIDString = ""; mysql_free_result( $rsGetPaymentModeIDString ); return( $GetPaymentModeIDString ); } function GetPaymentInfoCreditCard( $intCode ) { global $Session; $rs = mysql_query( "SELECT PaymentInfo FROM Customers WHERE Code = '" . $intCode . "'" ); if( $row = mysql_fetch_array( $rs )) { $str = $row[ "PaymentInfo" ]; $blnEnd = false; while( $blnEnd == false ) { if( is_int( strpos( $str, "#" ))) { $strPart = substr( $str, 0, strpos( $str, "#" )); $str = substr( $str, strpos( $str, "#" ) + 1); } else { $strPart = $str; $str = ""; $blnEnd = true; } if( strcmp( strtoupper(substr( $strPart, 0, strlen("CREDITCARD"))), "CREDITCARD" ) == 0 ) { $tok = strtok( $strPart, ":" ); $tok = strtok( ":" ); if( $tok ) { $Session["CreditCardType"] = $tok; $tok = strtok( ":" ); } if( $tok ) { $Session["CreditCardOwner"] = $tok ; $tok = strtok( ":" ); } if( $tok ) { $Session["CreditCardNumber"] = $tok; $tok = strtok( ":" ); } if( $tok ) { $Session["CreditCardExpirationMonth"] = $tok; $tok = strtok( ":" ); } if( $tok ) { $Session["CreditCardExpirationYear"] = $tok; $tok = strtok( ":" ); } $blnEnd = true; } } } else { return ""; } } function GetPaymentInfoDebitEntry( $intCode ) { global $Session; $rs = mysql_query( "SELECT PaymentInfo FROM Customers WHERE Code = '" . $intCode . "'" ); if( $row = mysql_fetch_array( $rs )) { $str = $row[ "PaymentInfo" ]; $blnEnd = false; while( $blnEnd == false ) { if( is_int( strpos( $str, "#" ))) { $strPart = substr( $str, 0, strpos( $str, "#" )); $str = substr( $str, strpos( $str, "#" ) + 1); } else { $strPart = $str; $str = ""; $blnEnd = true; } if( strcmp( strtoupper(substr( $strPart, 0, strlen("DebitEntry"))), "DEBITENTRY" ) == 0 ) { $tok = strtok( $strPart, ":" ); $tok = strtok( ":" ); if( $tok ) { $Session["DebitEntryName" ] = $tok; $tok = strtok( ":" ); } if( $tok ) { $Session["DebitEntryCode" ]= $tok; $tok = strtok( ":" ); } if( $tok ) { $Session["DebitEntryAccount" ] = $tok; $tok = strtok( ":" ); } $blnEnd = true; } } } else { return ""; } } function UpdatePaymentInfo( $intCode, $strPaymentInfo ) { $rs = mysql_query( "SELECT * FROM Customers WHERE Code='" . $intCode . "'"); if( $row = mysql_fetch_array( $rs )) { // ff2: field are not always set in the database if (!isset($row[ "PaymentInfo" ])) $row[ "PaymentInfo" ] = ''; $strOldPaymentInfo = $row[ "PaymentInfo" ]; if( Empty($strOldPaymentInfo) OR strlen( $strOldPaymentInfo ) == 0 ) { $strNewPaymentInfo = $strPaymentInfo; } else { $strPaymentMode = substr( $strPaymentInfo, 0, strpos( $strPaymentInfo, ":" ) ); $intPos = strpos( $strOldPaymentInfo, $strPaymentMode ); if( is_int( $intPos )) { if( $intPos == 0 ) $strNewPaymentInfo = $strPaymentInfo; else $strNewPaymentInfo = substr( $strOldPaymentInfo, 0, $intPos - 1 ) . "#" . $strPaymentInfo; if( is_int( strpos( $strOldPaymentInfo, "#", $intPos + 1 ))) $strNewPaymentInfo = $strNewPaymentInfo . "#" . substr( $strOldPaymentInfo, strpos( $strOldPaymentInfo, "#", $intPos + 1 ) + 1 ); } else { $strNewPaymentInfo = $strOldPaymentInfo . "#" . $strPaymentInfo; } } mysql_query( "UPDATE Customers SET PaymentInfo='" . CSQLString( $strNewPaymentInfo ) . "' WHERE Code='" . $intCode . "'"); } mysql_free_result( $rs );; } function DeletePaymentInfo( $intCode, $strPaymentMode ) { $rs = mysql_query( "SELECT * FROM Customers WHERE Code='" . $intCode . "'"); if( $row = mysql_fetch_array( $rs )) { // ff2: field is not always set in the database if (!isset($row[ "PaymentInfo" ])) $row[ "PaymentInfo" ]= ''; $strOldPaymentInfo = $row[ "PaymentInfo" ]; $intPos = strpos( $strOldPaymentInfo, $strPaymentMode ); if( is_int( $intPos )) { if( $intPos == 0 ) $strNewPaymentInfo = ""; else $strNewPaymentInfo = substr( $strOldPaymentInfo, 0, $intPos - 1 ); if( is_int( strpos( $strOldPaymentInfo, "#", $intPos + 1 ))) { if( strlen( $strNewPaymentInfo )) $strNewPaymentInfo = $strNewPaymentInfo ."#"; $strNewPaymentInfo = $strNewPaymentInfo . substr( $strOldPaymentInfo, strpos( $strOldPaymentInfo, "#", $intPos + 1 ) + 1 ); } mysql_query( "UPDATE Customers SET PaymentInfo='" . CSQLString( $strNewPaymentInfo ) . "' WHERE Code='" . $intCode . "'" ); } } mysql_free_result( $rs ); } //******************************************************************** // Country related functions //******************************************************************** function GetCountryName( $CountryID ) { $rsCountry = mysql_query( "SELECT Name FROM Countries WHERE CountryID = " . $CountryID ); if( $row = mysql_fetch_array( $rsCountry )) { return $row[ "Name" ]; } else { return ""; } } function GetStateName( $StateID ) { $rsState = mysql_query( "SELECT Name FROM States WHERE StateID = " . $StateID ); if( $row = mysql_fetch_array( $rsState )) { return $row[ "Name" ]; } else { return ""; } } //************************************************************** // Order functions //************************************************************** function GetCurrentOrdersPaymentInfo() { global $Session, $conn; $strOrderDescription = ""; if( 0 == strcmp( $Session[ "strPaymentModeIDString" ], "CreditCard" )) { $strPayOwner = WebEncode($Session[ "CreditCardOwner"]); $strPayNumber = WebEncode($Session[ "CreditCardNumber"]); $strPayDate = WebEncode($Session[ "CreditCardExpirationMonth"] . "/" .$Session[ "CreditCardExpirationYear"]); } elseif( 0 == strcmp( $Session[ "strPaymentModeIDString" ], "DebitEntry" )) { $strPayName = WebEncode($Session[ "DebitEntryName"]); $strPayAccount = WebEncode($Session[ "DebitEntryAccount"]); $strPayCode = WebEncode($Session[ "DebitEntryCode"]); } $rs = mysql_query( "SELECT OrderDescription FROM PaymentModes WHERE IDString = '" . $Session[ "strPaymentModeIDString" ] . "'" ); if( $row = mysql_fetch_array( $rs )) { $strOrderDescription = $row[ "OrderDescription" ]; if( 0 == strcmp( $Session[ "strPaymentModeIDString" ], "CreditCard" )) { $strOrderDescription = str_replace_i( "%strOwner%", $strPayOwner, $strOrderDescription ); $strOrderDescription = str_replace_i( "%strNumber%", $strPayNumber, $strOrderDescription ); $strOrderDescription = str_replace_i( "%strDate%", $strPayDate, $strOrderDescription ); } elseif( 0 == strcmp( $Session[ "strPaymentModeIDString" ], "DebitEntry" )) { $strOrderDescription = str_replace_i( "%strName%", $strPayName, $strOrderDescription ); $strOrderDescription = str_replace_i( "%strAccount%", $strPayAccount, $strOrderDescription ); $strOrderDescription = str_replace_i( "%strCode%", $strPayCode, $strOrderDescription ); } } mysql_free_result( $rs ); return( $strOrderDescription ); } function GetCurrentOrdersTariffInfo() { global $Session, $conn; // >> 010227 tl, OSC >> $res = ""; $aPieces = explode("_", $Session [ "intTariffID" ] ); if ( count($aPieces) == 1 ) { $rs = mysql_query( "SELECT OrderDescription FROM ShippingTariffs WHERE TariffID = " . $Session[ "intTariffID" ]); if( $row = mysql_fetch_array( $rs )) $res = $row[ "OrderDescription" ]; mysql_free_result( $rs ); } else { $res = $Session [ "OSCType_" . $aPieces[0] ] . ": " . $aPieces[1]; } return ($res); // << 010227 tl, OSC << } //******************************************************************* // Define offer object //******************************************************************* define("offer_icount", "18"); define("offer_i_ProductID", "1"); define("offer_i_Discount", "2"); define("offer_i_MinPrice", "3"); define("offer_i_MaxPrice" , "4"); define("offer_i_PriceString", "5"); define("offer_i_NetMinPrice", "6"); define("offer_i_NetMaxPrice" ,"7"); define("offer_i_NetPriceString", "8"); define("offer_i_Name", "9"); define("offer_i_Code", "10"); define("offer_i_ShortDescription", "11"); define("offer_i_FullDescription", "12"); define("offer_i_OfferText", "13"); define("offer_i_SmallImage", "14"); define("offer_i_Image", "15"); define("offer_i_ResultSet", "16"); define("offer_i_Row", "17"); define("offer_i_Available", "18"); function GetOfferObject( &$OfferObject) { global $Session; $row = $OfferObject[offer_i_Row]; if( $row ) { $OfferObject[ offer_i_ProductID ] = $row["Nr"]; $intTax = GetTax( $OfferObject[ offer_i_ProductID ], $Session[ "CurrencyID" ], $Session[ "PriceGroupID" ] ); $OfferObject[ offer_i_Discount ] = $row["MaxDiscount"]; $OfferObject[ offer_i_Available ] = $row["Available"]; $OfferObject[ offer_i_MinPrice ] = $row["MinPrice"]; $OfferObject[ offer_i_MaxPrice ] = $row["MaxPrice"]; //010205 tl, OTC //$OfferObject[ offer_i_PriceString ] = GetPriceString( $OfferObject[ offer_i_ProductID ], $OfferObject[ offer_i_MinPrice ], $OfferObject[ offer_i_MaxPrice ], $OfferObject[ offer_i_Discount ], 0, false, $row["PricePresentationID"], $Session["PriceGroupID"] ); $OfferObject[ offer_i_PriceString ] = GetPriceString( $OfferObject[ offer_i_ProductID ], $OfferObject[ offer_i_MinPrice ], $OfferObject[ offer_i_MaxPrice ], $OfferObject[ offer_i_Discount ], $intTax, false, $row["PricePresentationID"], $Session["PriceGroupID"], false ); $OfferObject[ offer_i_NetMinPrice ] = GetNetto( $OfferObject[ offer_i_MinPrice ], $intTax); $OfferObject[ offer_i_NetMaxPrice ] = GetNetto( $OfferObject[ offer_i_MaxPrice ], $intTax); $OfferObject[ offer_i_NetPriceString ] = GetPriceString( $OfferObject[ offer_i_ProductID ], $OfferObject[ offer_i_MinPrice ], $OfferObject[ offer_i_MaxPrice ], $OfferObject[ offer_i_Discount ], $intTax, true, $row["PricePresentationID"], $Session["PriceGroupID"], false ); if (!isset($row["Name"])) $row["Name"]=''; $OfferObject[ offer_i_Name ] = $row["Name"]; if (!isset($row["Code"])) $row["Code"]=''; $OfferObject[ offer_i_Code ] = $row["Code"]; if (!isset($row["ShortDescription"])) $row["ShortDescription"]=''; $OfferObject[ offer_i_ShortDescription ] = $row["ShortDescription"]; if (!isset($row["FullDescription"])) $row["FullDescription"]=''; $OfferObject[ offer_i_FullDescription ] = $row["FullDescription"]; if (!isset($row["Text"])) $row["Text"]=''; $OfferObject[ offer_i_OfferText ] = $row["Text"]; if (!isset($row["Image"])) $row["Image"]=''; $OfferObject[ offer_i_Image ] = $row["Image"]; if (!isset($row["SmallImage"])) $row["SmallImage"]=''; $OfferObject[ offer_i_SmallImage ] = $row["SmallImage"]; } return($OfferObject); } function IsLastOfferObject( &$OfferObject ) { if($OfferObject[offer_i_Row]) { return(false); } else { return(true); } } function GetNextOfferObject( &$OfferObject ) { $GetNextOfferObjectStop = false; $GetNextOfferObjectLastNr = $OfferObject[ offer_i_ProductID ]; $OfferObject[ offer_i_Row ] = mysql_fetch_array( $OfferObject[ offer_i_ResultSet ] ); $OfferObject = GetOfferObject($OfferObject); while ($GetNextOfferObjectStop == false) { if (IsLastOfferObject($OfferObject)) { $GetNextOfferObjectStop = true; } else { if ($GetNextOfferObjectLastNr == $OfferObject[offer_i_ProductID]) { $GetNextOfferObjectLastNr = $OfferObject[ offer_i_ProductID ]; $OfferObject[ offer_i_Row ] = mysql_fetch_array( $OfferObject[ offer_i_ResultSet ] ); $OfferObject = GetOfferObject($OfferObject); } else { $GetNextOfferObjectStop = true; } } } return (GetOfferObject( $OfferObject )); } function GetFirstOfferObject( $intType ) { global $Session; $sqlProductsPromotion = "SELECT " . "Products.ProductID AS Nr, " . "Promotions.Discount AS MaxDiscount, " . "cchMinMaxProductPrices.MinPrice, " . "cchMinMaxProductPrices.MaxPrice, " . "Products.Name, " . "Products.Code, " . "Products.ShortDescription, " . "Products.SmallImage, " . "Products.Available, " . "Products.Image, " . "Products.PricePresentationID, " . "Promotions.Text, " . "Products.FullDescription " . "FROM (Products LEFT JOIN cchMinMaxProductPrices ON Products.ProductID = cchMinMaxProductPrices.ProductID) LEFT JOIN Promotions ON Products.ProductID = Promotions.ProductID " . "WHERE " . $Session[ "strCustomerCategories" ] . "AND ((Promotions.BeginDate)<=" . SQLDate() . ") AND ((Promotions.EndDate)>=" . SQLDate() . ") " . "AND ((Promotions.CheckInOutOffer)= " . $intType . ") " . "AND ((Products.Inactive)=0) " . "AND ((cchMinMaxProductPrices.CurrencyID)=" . $Session[ "CurrencyID" ] . ") " . "AND ((cchMinMaxProductPrices.PriceGroupID)=" . $Session[ "PriceGroupID" ] . ") " . "AND Products.DeleteStatus=0 AND Promotions.DeleteStatus=0 " . "ORDER BY Products.ProductID, Promotions.Discount DESC "; //dep ("GetFirstOfferObject-SQL: " . $sqlProductsPromotion); $OfferObject[offer_i_ResultSet] = mysql_query( $sqlProductsPromotion ); $OfferObject[offer_i_Row] = mysql_fetch_array($OfferObject[offer_i_ResultSet]); return (GetOfferObject( $OfferObject )); } // get normal offers - ULI function GetFirstOfferNormalObject( $intType ) { global $Session; $sqlProductsPromotion = "SELECT " . "Products.ProductID AS Nr, " . "Promotions.Discount AS MaxDiscount, " . "cchMinMaxProductPrices.MinPrice, " . "cchMinMaxProductPrices.MaxPrice, " . "Products.Name, " . "Products.Code, " . "Products.ShortDescription, " . "Products.SmallImage, " . "Products.Available, " . "Products.Image, " . "Products.PricePresentationID, " . "Promotions.Text, " . "Products.FullDescription " . "FROM (Products LEFT JOIN cchMinMaxProductPrices ON Products.ProductID = cchMinMaxProductPrices.ProductID) LEFT JOIN Promotions ON Products.ProductID = Promotions.ProductID " . "WHERE " . $Session[ "strCustomerCategories" ] . "AND ((Promotions.BeginDate)<=" . SQLDate() . ") AND ((Promotions.EndDate)>=" . SQLDate() . ") " . "AND (Promotions.JoinedProductID IS NULL) " . "AND ((Promotions.CheckInOutOffer)= " . $intType . ") " . "AND ((Products.Inactive)=0) " . "AND ((cchMinMaxProductPrices.CurrencyID)=" . $Session[ "CurrencyID" ] . ") " . "AND ((cchMinMaxProductPrices.PriceGroupID)=" . $Session[ "PriceGroupID" ] . ") " . "AND Products.DeleteStatus=0 AND Promotions.DeleteStatus=0 " . "ORDER BY Products.ProductID, Promotions.Discount DESC "; //dep ("GetFirstOfferObject-SQL: " . $sqlProductsPromotion); $OfferObject[offer_i_ResultSet] = mysql_query( $sqlProductsPromotion ); $OfferObject[offer_i_Row] = mysql_fetch_array($OfferObject[offer_i_ResultSet]); return (GetOfferObject( $OfferObject )); } // get normal offers with small pictures - ULI function GetFirstOfferNormalPicObject( $intType ) { global $Session; $sqlProductsPromotion = "SELECT " . "Products.ProductID AS Nr, " . "Promotions.Discount AS MaxDiscount, " . "cchMinMaxProductPrices.MinPrice, " . "cchMinMaxProductPrices.MaxPrice, " . "Products.Name, " . "Products.Code, " . "Products.ShortDescription, " . "Products.SmallImage, " . "Products.Available, " . "Products.Image, " . "Products.PricePresentationID, " . "Promotions.Text, " . "Products.FullDescription " . "FROM (Products LEFT JOIN cchMinMaxProductPrices ON Products.ProductID = cchMinMaxProductPrices.ProductID) LEFT JOIN Promotions ON Products.ProductID = Promotions.ProductID " . "WHERE " . $Session[ "strCustomerCategories" ] . "AND ((Promotions.BeginDate)<=" . SQLDate() . ") AND ((Promotions.EndDate)>=" . SQLDate() . ") " . "AND (Promotions.JoinedProductID IS NULL) " . "AND ((Promotions.CheckInOutOffer)= " . $intType . ") " . "AND ((Products.Inactive)=0) " . "AND (Products.SmallImage IS NOT NULL) " . "AND ((cchMinMaxProductPrices.CurrencyID)=" . $Session[ "CurrencyID" ] . ") " . "AND ((cchMinMaxProductPrices.PriceGroupID)=" . $Session[ "PriceGroupID" ] . ") " . "AND Products.DeleteStatus=0 AND Promotions.DeleteStatus=0 " . "ORDER BY Products.ProductID, Promotions.Discount DESC "; //dep ("GetFirstOfferObject-SQL: " . $sqlProductsPromotion); $OfferObject[offer_i_ResultSet] = mysql_query( $sqlProductsPromotion ); $OfferObject[offer_i_Row] = mysql_fetch_array($OfferObject[offer_i_ResultSet]); return (GetOfferObject( $OfferObject )); } //******************************************************************* // Order progress functions //******************************************************************* function GoOrderProgressNext() { global $Session; $Session["intOrderProgress"] = $Session["intOrderProgress"]+1; //dep("GoOrderProgressNext: " . $Session[ "intOrderProgress" ]); $Session["blnOrderProgressMovedForward"] = "true"; switch($Session["intOrderProgress"]) { case 0: Jump("Cart.php"); break; case 1: Jump("Offer.php"); break; case 2: if ($Session["Code"] == "") { Jump("Login.php?NextPage=Modes.php"); } else { Jump("Modes.php"); } break; case 3: if (($Session["strPaymentModeIDString"] == "CreditCard") or ( $Session["strPaymentModeIDString"] == "DebitEntry")) { Jump("PaymentData.php"); } elseif (($Session["strPaymentModeIDString"] == "SSLCC") or ($Session["strPaymentModeIDString"] == "SSLEDD")) { Jump(GetAsSSLPage("PaymentData.php")); } else { GoOrderProgressNext(); } break; case 4: Jump("Order.php"); break; } } function GoOrderProgressBack() { global $Session; //dep("GoOrderProgressNext: " . $Session[ "intOrderProgress" ]); $Session["intOrderProgress"] = $Session["intOrderProgress"] - 1; $Session["blnOrderProgressMovedForward"] = ""; switch ($Session["intOrderProgress"]) { case 0: Jump("Cart.php"); break; case 1: Jump("Offer.php"); break; case 2: Jump(GetAsNoSSLPage("Modes.php")); break; case 3: if (($Session["strPaymentModeIDString"] == "CreditCard") or ($Session["strPaymentModeIDString"] == "DebitEntry")) { Jump("PaymentData.php"); } //010320 tl, bugzilla #173 elseif (($Session["strPaymentModeIDString"] == "SSLCC") or ( $Session["strPaymentModeIDString"] == "SSLEDD")) { Jump(GetAsSSLPage("PaymentData.php")); } else { GoOrderProgressBack(); } break; case 4: Jump("Order.php"); break; } } function GoOrderProgressStep() { global $Session; // ff2: if ($Session["blnOrderProgressMovedForward"] == true) if ($Session["blnOrderProgressMovedForward"]) { GoOrderProgressNext(); } else { GoOrderProgressBack(); } } function GoOrderProgressStart() { global $Session; //dep("Start OrderProgress"); $Session["intOrderProgress"] = 0; GoOrderProgressNext(); echo "Hallo2"; } //******************************************************************* //* Define ProductRecord object //******************************************************************* define("productrecord_icount", "24"); define("productrecord_i_ID", "1"); define("productrecord_i_Discount", "2"); define("productrecord_i_MinPrice", "3"); define("productrecord_i_MaxPrice", "4"); define("productrecord_i_PriceString", "5"); define("productrecord_i_NetMinPrice", "6"); define("productrecord_i_NetMaxPrice", "7"); define("productrecord_i_NetPriceString", "8"); define("productrecord_i_Name", "9"); define("productrecord_i_Code", "10"); define("productrecord_i_ShortDescription", "11"); define("productrecord_i_FullDescription", "12"); define("productrecord_i_SmallImage", "14"); define("productrecord_i_Image", "15"); define("productrecord_i_PricePresentationID", "16"); define("productrecord_i_Category", "17"); define("productrecord_i_Available", "18"); define("productrecord_i_OrderQuantity", "19"); define("productrecord_i_PResultSet", "20"); define("productrecord_i_CResultSet", "21"); define("productrecord_i_PRow", "22"); define("productrecord_i_CRow", "23"); define("productrecord_i_PLResultSet", "24"); define("productrecord_i_CLResultSet", "25"); define("productrecord_i_PLRow", "26"); define("productrecord_i_CLRow", "27"); define("productrecord_i_Row", "28"); function GetVariantCategoryAvailable($CategoryID) { $sql = "SELECT Sum(Products.Available) AS Available FROM Products WHERE Products.CategoryID=" . $CategoryID; $rs = mysql_query( $sql ); $row = mysql_fetch_array( $rs ); if ($row) return($row["Available"]); else return("---"); mysql_free_result($rs); } function GetProductRecordObject( &$ProductRecordObject ) { global $Session; $Row = $ProductRecordObject[productrecord_i_Row]; if ($Row) { $ProductRecordObject[ productrecord_i_ID ] = $Row["Nr"]; $ProductRecordObject[productrecord_i_Category] = $Row["Category"]; if (($ProductRecordObject[productrecord_i_Category] == 1) or ($ProductRecordObject[productrecord_i_Category] == 3)) { $intTax = GetTaxByVariantCategory( $ProductRecordObject[ productrecord_i_ID ], $Session["CurrencyID"], $Session["PriceGroupID"]); $ProductRecordObject[productrecord_i_Available] = GetVariantCategoryAvailable($ProductRecordObject[ productrecord_i_ID]); } else { $intTax = GetTax( $ProductRecordObject[ productrecord_i_ID ], $Session["CurrencyID"], $Session["PriceGroupID"]); $ProductRecordObject[productrecord_i_Available] = $Row["Available"]; } if( $Row[ "Category" ] == 0 or $Row[ "Category" ] == 2 ) $ProductRecordObject[productrecord_i_Discount] = GetMaxDiscount( $Row[ "Nr" ]); else $ProductRecordObject[productrecord_i_Discount] = GetMaxDiscountFromCategory( $Row[ "Nr" ]); $ProductRecordObject[productrecord_i_MinPrice] = $Row["MinPrice"]; $ProductRecordObject[productrecord_i_MaxPrice] = $Row["MaxPrice"]; // 010223 tl, OTC //$ProductRecordObject[productrecord_i_PriceString] = GetPriceString( $ProductRecordObject[productrecord_i_ID], $ProductRecordObject[productrecord_i_MinPrice], $ProductRecordObject[productrecord_i_MaxPrice], $ProductRecordObject[productrecord_i_Discount], 0, false, $Row["PricePresentationID"], $Session["PriceGroupID"]); $ProductRecordObject[productrecord_i_PriceString] = GetPriceString( $ProductRecordObject[productrecord_i_ID], $ProductRecordObject[productrecord_i_MinPrice], $ProductRecordObject[productrecord_i_MaxPrice], $ProductRecordObject[productrecord_i_Discount], $intTax, false, $Row["PricePresentationID"], $Session["PriceGroupID"], $Row[ "Category" ]); $ProductRecordObject[productrecord_i_NetMinPrice] = GetNetto( $Row["MinPrice"], $intTax ); $ProductRecordObject[productrecord_i_NetMaxPrice] = GetNetto( $Row["MaxPrice"], $intTax ); $ProductRecordObject[productrecord_i_NetPriceString] = GetPriceString( $ProductRecordObject[productrecord_i_ID], $ProductRecordObject[productrecord_i_MinPrice], $ProductRecordObject[productrecord_i_MaxPrice], $ProductRecordObject[productrecord_i_Discount], $intTax, true, $Row["PricePresentationID"], $Session["PriceGroupID"], $Row[ "Category" ]); $ProductRecordObject[productrecord_i_Name] = $Row["Name"]; // ff2!: fields are not always set in the database if (!isset($Row["ShortDescription"])) $Row["ShortDescription"]=''; if (!isset($Row["FullDescription"])) $Row["FullDescription"]=''; if (!isset($Row["SmallImage"])) $Row["SmallImage"]=''; if (!isset($Row["Image"])) $Row["Image"]=''; if (!isset($Row["Code"])) $Row["Code"]=''; if (!isset($Row["PricePresentationID"])) $Row["PricePresentationID"]=''; $ProductRecordObject[productrecord_i_Code] = $Row["Code"]; $ProductRecordObject[productrecord_i_ShortDescription] = $Row["ShortDescription"]; $ProductRecordObject[productrecord_i_FullDescription] = $Row["FullDescription"]; $ProductRecordObject[productrecord_i_SmallImage] = $Row["SmallImage"]; $ProductRecordObject[productrecord_i_Image] = $Row["Image"]; $ProductRecordObject[productrecord_i_PricePresentationID] = $Row["PricePresentationID"]; } else { } return ($ProductRecordObject); } function IsLastProductRecordObject( &$ProductRecordObject ) { if (count($ProductRecordObject[productrecord_i_Row])>1) return(false); else return(true); } function GetNextProductRecordObject( &$ProductRecordObject ) { if( $ProductRecordObject[productrecord_i_Row][ "Category" ] == 0 ) { $ProductRecordObject[productrecord_i_PRow] = mysql_fetch_array( $ProductRecordObject[productrecord_i_PResultSet] ); } elseif($ProductRecordObject[productrecord_i_Row][ "Category" ] == 1) { $ProductRecordObject[productrecord_i_CRow] = mysql_fetch_array( $ProductRecordObject[productrecord_i_CResultSet] ); } elseif($ProductRecordObject[productrecord_i_Row][ "Category" ] == 2) { $ProductRecordObject[productrecord_i_PLRow] = mysql_fetch_array( $ProductRecordObject[productrecord_i_PLResultSet] ); } elseif($ProductRecordObject[productrecord_i_Row][ "Category" ] == 3) { $ProductRecordObject[productrecord_i_CLRow] = mysql_fetch_array( $ProductRecordObject[productrecord_i_CLResultSet] ); } $RecordSet = getNextProduct($ProductRecordObject[productrecord_i_PRow]["Name"], $ProductRecordObject[productrecord_i_CRow]["Name"], $ProductRecordObject[productrecord_i_PLRow]["Name"], $ProductRecordObject[productrecord_i_CLRow]["Name"]); switch ($RecordSet) { case -1: unset($ProductRecordObject[productrecord_i_Row]); break; case 0: $ProductRecordObject[productrecord_i_Row] = $ProductRecordObject[productrecord_i_PRow]; break; case 1: $ProductRecordObject[productrecord_i_Row] = $ProductRecordObject[productrecord_i_CRow]; break; case 2: $ProductRecordObject[productrecord_i_Row] = $ProductRecordObject[productrecord_i_PLRow]; break; case 3: $ProductRecordObject[productrecord_i_Row] = $ProductRecordObject[productrecord_i_CLRow]; break; } return (GetProductRecordObject( $ProductRecordObject )); } function GetFirstProductRecordObject( $intCategoryID ) { global $Session; if ($intCategoryID <> -1) { $sqlwhere = "AND (Products.CategoryID=" . $intCategoryID . ") "; $sqlcwhere = "AND (ProductCategories.TopCategoryID=" . $intCategoryID . ") "; $sqllwhere = "AND (ProductLinks.CategoryID=" . $intCategoryID . ") "; $sqllcwhere = "AND (CategoryLinks.ParentCategoryID=" . $intCategoryID . ") "; } else { $sqlwhere = ""; $sqlcwhere = ""; $sqllwhere = ""; $sqllcwhere = ""; } $sqlProducts = "SELECT " . "0 as Category, " . "Products.ProductID as Nr, " . "Products.Code, " . "Products.Name, " . "cchMinMaxProductPrices.MinPrice, " . "cchMinMaxProductPrices.MaxPrice, " . "Products.ShortDescription, " . "Products.SmallImage, " . "Products.Image, " . "Products.Inactive, " . "Products.Available, " . "Products.PricePresentationID, " . "Products.FullDescription " . "FROM (Products LEFT JOIN cchMinMaxProductPrices ON Products.ProductID = cchMinMaxProductPrices.ProductID) " . "WHERE ((Products.Variants='') OR (Products.Variants is null))" . "AND (Products.Inactive=0) " . "AND (cchMinMaxProductPrices.CurrencyID=" . $Session[ "CurrencyID" ] . ") " . "AND (cchMinMaxProductPrices.PriceGroupID=" . $Session[ "PriceGroupID" ] . ") " . "AND (Products.DeleteStatus=0) "; $sqlProducts = $sqlProducts . $sqlwhere . "ORDER BY Name"; $sqlCategories = "SELECT " . "1 as Category, " . "ProductCategories.CategoryID as Nr, " . "'' AS Code, " . "ProductCategories.Name, " . "cchMinMaxVariantCategoryPrices.MinPrice, " . "cchMinMaxVariantCategoryPrices.MaxPrice, " . "ProductCategories.ShortDescription, " . "ProductCategories.SmallImage, " . "ProductCategories.Image, " . "ProductCategories.Inactive, " . "ProductCategories.PricePresentationID, " . "ProductCategories.FullDescription " . "FROM ProductCategories LEFT JOIN cchMinMaxVariantCategoryPrices ON ProductCategories.CategoryID = cchMinMaxVariantCategoryPrices.CategoryID " . "WHERE (cchMinMaxVariantCategoryPrices.CurrencyID=" . $Session[ "CurrencyID" ] . ") " . "AND (cchMinMaxVariantCategoryPrices.PriceGroupID=" . $Session[ "PriceGroupID" ] . ") " . "AND (ProductCategories.Inactive=0) " . "AND (ProductCategories.DeleteStatus=0) "; $sqlCategories = $sqlCategories . $sqlcwhere . "ORDER BY Name"; $sqlProductLinks = "SELECT " . "Products.ProductID As Nr, " . "Products.Code, " . "Products.Name, " . "Products.Available, " . "cchMinMaxProductPrices.MinPrice, " . "cchMinMaxProductPrices.MaxPrice, " . "2 AS Category, " . "Products.ShortDescription, " . "Products.SmallImage, " . "Products.Image, " . "Products.PricePresentationID, " . "Products.FullDescription " . "FROM (Products LEFT JOIN ProductLinks ON (Products.ProductID = ProductLinks.ProductID) AND (Products.ProductID = ProductLinks.ProductID)) LEFT JOIN cchMinMaxProductPrices ON Products.ProductID = cchMinMaxProductPrices.ProductID " . "WHERE ProductLinks.CategoryID=" . $intCategoryID . " " . "AND ProductLinks.Deletestatus=0 " . "AND cchMinMaxProductPrices.CurrencyID=" . $Session["CurrencyID"] . " " . "AND cchMinMaxProductPrices.PriceGroupID=" . $Session["PriceGroupID"] . " "; $sqlProductLinks = $sqlProductLinks . $sqllwhere . "ORDER BY Name"; $sqlCategoryLinks = "SELECT " . "ProductCategories.CategoryID As Nr, " . "'', " . "ProductCategories.Name, " . "cchMinMaxVariantCategoryPrices.MinPrice, " . "cchMinMaxVariantCategoryPrices.MaxPrice, " . "3 AS Category, " . "ProductCategories.ShortDescription, " . "ProductCategories.SmallImage, " . "ProductCategories.Image, " . "ProductCategories.PricePresentationID, " . "ProductCategories.FullDescription " . "FROM (CategoryLinks LEFT JOIN ProductCategories ON CategoryLinks.CategoryID = ProductCategories.CategoryID) LEFT JOIN cchMinMaxVariantCategoryPrices ON CategoryLinks.CategoryID = cchMinMaxVariantCategoryPrices.CategoryID " . "WHERE cchMinMaxVariantCategoryPrices.CurrencyID=" . $Session["CurrencyID"] . " " . "AND cchMinMaxVariantCategoryPrices.PriceGroupID=" . $Session["PriceGroupID"] . " " . "AND ProductCategories.Inactive=0 " . "AND ProductCategories.DeleteStatus=0 "; $sqlCategoryLinks = $sqlCategoryLinks . $sqllcwhere . "ORDER BY Name"; //dep("Products: " . $sqlProducts . "

"); //dep("Categories: " . $sqlCategories . "

"); //dep("ProductLinks: " . $sqlProductLinks . "

"); //dep("CategoryLinks: " . $sqlCategoryLinks . "

"); $ProductRecordObject[productrecord_i_PResultSet] = mysql_query( $sqlProducts ); $ProductRecordObject[productrecord_i_CResultSet] = mysql_query( $sqlCategories ); $ProductRecordObject[productrecord_i_PLResultSet] = mysql_query( $sqlProductLinks ); $ProductRecordObject[productrecord_i_CLResultSet] = mysql_query( $sqlCategoryLinks ); $ProductRecordObject[productrecord_i_PRow] = mysql_fetch_array($ProductRecordObject[productrecord_i_PResultSet]); $ProductRecordObject[productrecord_i_CRow] = mysql_fetch_array($ProductRecordObject[productrecord_i_CResultSet]); $ProductRecordObject[productrecord_i_PLRow] = mysql_fetch_array($ProductRecordObject[productrecord_i_PLResultSet]); $ProductRecordObject[productrecord_i_CLRow] = mysql_fetch_array($ProductRecordObject[productrecord_i_CLResultSet]); //dep("NEXTPROD: " . getNextProduct($ProductRecordObject[productrecord_i_PRow]["Name"], $ProductRecordObject[productrecord_i_CRow]["Name"], $ProductRecordObject[productrecord_i_PLRow]["Name"], $ProductRecordObject[productrecord_i_CLRow]["Name"])); $RecordSet = getNextProduct($ProductRecordObject[productrecord_i_PRow]["Name"], $ProductRecordObject[productrecord_i_CRow]["Name"], $ProductRecordObject[productrecord_i_PLRow]["Name"], $ProductRecordObject[productrecord_i_CLRow]["Name"]); switch ($RecordSet) { case 0: $ProductRecordObject[productrecord_i_Row] = $ProductRecordObject[productrecord_i_PRow]; break; case 1: $ProductRecordObject[productrecord_i_Row] = $ProductRecordObject[productrecord_i_CRow]; break; case 2: $ProductRecordObject[productrecord_i_Row] = $ProductRecordObject[productrecord_i_PLRow]; break; case 3: $ProductRecordObject[productrecord_i_Row] = $ProductRecordObject[productrecord_i_CLRow]; break; } return (GetProductRecordObject( $ProductRecordObject )); } function GetProductRecordRecordCount( &$ProductRecordObject ) { return( mysql_num_rows($ProductRecordObject[productrecord_i_PResultSet]) + mysql_num_rows($ProductRecordObject[productrecord_i_CResultSet]) + mysql_num_rows($ProductRecordObject[productrecord_i_PLResultSet]) + mysql_num_rows($ProductRecordObject[productrecord_i_CLResultSet])); } function getNextProduct( $s, $t, $a, $b ) { $strArray[0] = $s; $strArray[1] = $t; $strArray[2] = $a; $strArray[3] = $b; $intNumber = -1; if ($strArray[0]) $intNumber = 0; if ($strArray[1] and $intNumber==-1) $intNumber = 1; if ($strArray[2] and $intNumber==-1) $intNumber = 2; if ($strArray[3] and $intNumber==-1) $intNumber = 3; if ($strArray[0] && $strArray[1]) { if (strcasecmp( $strArray[0], $strArray[1] ) < 0 ) $intNumber = 0; else $intNumber = 1; } // ff2: we dont want $intNumber<0, don't we? if ($intNumber<0) return; if ($strArray[$intNumber] && $strArray[2]) { if (strcasecmp( $strArray[$intNumber], $strArray[2] ) < 0 ) $intNumber = $intNumber; else $intNumber = 2; } if ($strArray[$intNumber] && $strArray[3]) { if (strcasecmp( $strArray[$intNumber], $strArray[3] ) < 0 ) $intNumber = $intNumber; else $intNumber = 3; } return $intNumber; } //******************************************************************* //* Define ProductCategoryRecord object //******************************************************************* define("categoryrecord_icount", "11"); define("categoryrecord_i_ID", "1"); define("categoryrecord_i_Name", "2"); define("categoryrecord_i_ShortDescription", "3"); define("categoryrecord_i_FullDescription", "4"); define("categoryrecord_i_SmallImage", "5"); define("categoryrecord_i_Image", "6"); define("categoryrecord_i_CResultSet", "7"); define("categoryrecord_i_CRow", "8"); define("categoryrecord_i_CLResultSet", "9"); define("categoryrecord_i_CLRow", "10"); define("categoryrecord_i_Row", "11"); function GetCategoryRecordObject( &$CategoryRecordObject ) { global $Session; $Row = $CategoryRecordObject[categoryrecord_i_Row]; if ($Row) { $CategoryRecordObject[ categoryrecord_i_ID ] = $Row["Nr"]; // ff2: this is not used, so kick it!! //$CategoryRecordObject[categoryrecord_i_Category] = $Row["Category"]; $CategoryRecordObject[categoryrecord_i_Name] = $Row["Name"]; // ff2: fields are not always set in the database if (!isset($Row["ShortDescription"])) $Row["ShortDescription"]=''; if (!isset($Row["FullDescription"])) $Row["FullDescription"]=''; if (!isset($Row["SmallImage"])) $Row["SmallImage"]=''; if (!isset($Row["Image"])) $Row["Image"]=''; $CategoryRecordObject[categoryrecord_i_ShortDescription] = $Row["ShortDescription"]; $CategoryRecordObject[categoryrecord_i_FullDescription] = $Row["FullDescription"]; $CategoryRecordObject[categoryrecord_i_SmallImage] = $Row["SmallImage"]; $CategoryRecordObject[categoryrecord_i_Image] = $Row["Image"]; } else { } return ($CategoryRecordObject); } function IsLastCategoryRecordObject( &$CategoryRecordObject ) { if (count($CategoryRecordObject[categoryrecord_i_Row])>1) return(false); else return(true); } function GetNextCategoryRecordObject( &$CategoryRecordObject ) { if( $CategoryRecordObject[categoryrecord_i_Row][ "Link" ] == 0 ) { $CategoryRecordObject[categoryrecord_i_CRow] = mysql_fetch_array( $CategoryRecordObject[categoryrecord_i_CResultSet] ); } else { $CategoryRecordObject[categoryrecord_i_CLRow] = mysql_fetch_array( $CategoryRecordObject[categoryrecord_i_CLResultSet] ); } $CategoryRecordObject[categoryrecord_i_Row] = mystrcmp( $CategoryRecordObject[categoryrecord_i_CLRow]["Name"], $CategoryRecordObject[categoryrecord_i_CRow]["Name"]) < 0 ? $CategoryRecordObject[categoryrecord_i_CLRow] : $CategoryRecordObject[categoryrecord_i_CRow]; return (GetCategoryRecordObject( $CategoryRecordObject )); } function GetFirstCategoryRecordObject( $intCategoryID ) { global $Session; if( empty( $intCategoryID )) { $sqlcwhere = "TopCategoryID is Null"; $sqlclwhere = "ParentCategoryID is Null"; } else { $sqlcwhere = "TopCategoryID=" . $intCategoryID; $sqlclwhere = "ParentCategoryID=" . $intCategoryID; } $sqlCategories = "SELECT " . "ProductCategories.Name As Name, " . "0 As Link, " . "ProductCategories.Image, " . "ProductCategories.CategoryID As Nr, " . "ProductCategories.TopCategoryID, " . "ProductCategories.FullDescription " . "FROM " . "ProductCategories " . "WHERE " . "DeleteStatus=0 AND " . $sqlcwhere . " AND " . "VariantCategory = 0 AND " . "Inactive = 0 " . "ORDER BY " . "Name "; $sqlCategoryLinks = "SELECT " . "ProductCategories.Name As Name, " . "1 As Link, " . "ProductCategories.Image, " . "ProductCategories.CategoryID As Nr, " . "CategoryLinks.ParentCategoryID, " . "ProductCategories.FullDescription " . "FROM " . "CategoryLinks LEFT JOIN ProductCategories ON CategoryLinks.CategoryID = ProductCategories.CategoryID " . "WHERE " . "ProductCategories.DeleteStatus=0 AND " . $sqlclwhere . " AND " . "ProductCategories.VariantCategory = 0 AND " . "ProductCategories.Inactive = 0 AND " . "CategoryLinks.DeleteStatus = 0 " . "ORDER BY " . "Name "; //dep("Categories: " . $sqlCategories . "

"); //dep("CategoryLinks: " . $sqlCategoryLinks . "

"); $CategoryRecordObject[categoryrecord_i_CResultSet] = mysql_query( $sqlCategories ); $CategoryRecordObject[categoryrecord_i_CLResultSet] = mysql_query( $sqlCategoryLinks ); $CategoryRecordObject[categoryrecord_i_CRow] = mysql_fetch_array($CategoryRecordObject[categoryrecord_i_CResultSet]); $CategoryRecordObject[categoryrecord_i_CLRow] = mysql_fetch_array($CategoryRecordObject[categoryrecord_i_CLResultSet]); $CategoryRecordObject[categoryrecord_i_Row] = mystrcmp( $CategoryRecordObject[categoryrecord_i_CRow]["Name"], $CategoryRecordObject[categoryrecord_i_CLRow]["Name"]) < 0 ? $CategoryRecordObject[categoryrecord_i_CRow] : $CategoryRecordObject[categoryrecord_i_CLRow]; return (GetCategoryRecordObject( $CategoryRecordObject )); } function GetCategoryRecordRecordCount( &$CategoryRecordObject ) { return( mysql_num_rows($CategoryRecordObject[categoryrecord_i_CResultSet]) + mysql_num_rows($CategoryRecordObject[categoryrecord_i_CLResultSet])); } //******************************************************************* //* Define Search object //******************************************************************* define("search_icount", "19"); define("search_i_ID", "1"); define("search_i_Discount", "2"); define("search_i_MinPrice", "3"); define("search_i_MaxPrice", "4"); define("search_i_PriceString", "5"); define("search_i_NetMinPrice", "6"); define("search_i_NetMaxPrice", "7"); define("search_i_NetPriceString", "8"); define("search_i_Name", "9"); define("search_i_Code", "10"); define("search_i_ShortDescription", "11"); define("search_i_FullDescription", "12"); define("search_i_SmallImage", "14"); define("search_i_Image", "15"); define("search_i_PricePresentationID", "16"); define("search_i_Available", "17"); define("search_i_ResultSet", "18"); define("search_i_Row", "19"); define("search_i_CategoryID", "20"); function GetSearchObject( &$SearchObject ) { global $Session; $row = $SearchObject[search_i_Row]; // dep("Name: " . $row["Name"]); if (count($row)>1) { $SearchObject[search_i_ID] = $row["Nr"]; $intTax = GetTax( $SearchObject[search_i_ID], $Session["CurrencyID"], $Session["PriceGroupID"]); $SearchObject[search_i_Discount] = GetMaxDiscount($SearchObject[search_i_ID]); $SearchObject[search_i_MinPrice] = $row["MinPrice"]; $SearchObject[search_i_MaxPrice] = $row["MaxPrice"]; $SearchObject[search_i_PricePresentationID] = $row["PricePresentationID"]; $SearchObject[search_i_PriceString] = GetPriceString( $SearchObject[search_i_ID], $SearchObject[search_i_MinPrice], $SearchObject[search_i_MaxPrice], $SearchObject[search_i_Discount], 0, false, $SearchObject[search_i_PricePresentationID], $Session["PriceGroupID"], false ); $SearchObject[search_i_NetMinPrice] = GetNetto( $row["MinPrice"], $intTax); $SearchObject[search_i_NetMaxPrice] = GetNetto( $row["MaxPrice"], $intTax ); $SearchObject[search_i_NetPriceString] = GetPriceString( $SearchObject[search_i_ID], $SearchObject[search_i_MinPrice], $SearchObject[search_i_MaxPrice], $SearchObject[search_i_Discount], 0, false, $SearchObject[search_i_PricePresentationID], $Session["PriceGroupID"], false ); $SearchObject[search_i_Name] = $row["Name"]; // ff2: fields are not always set in the database if (!isset($row[ "Code" ])) $row[ "Code" ]=''; if (!isset($row[ "Available" ])) $row[ "Available" ] = ''; if (!isset($row[ "ShortDescription" ])) $row[ "ShortDescription" ]=''; if (!isset($row[ "Image" ])) $row[ "Image" ]=''; if (!isset($row[ "SmallImage" ])) $row[ "SmallImage" ]=''; if (!isset($row[ "FullDescription" ])) $row[ "FullDescription" ]=''; $SearchObject[search_i_Code] = $row["Code"]; $SearchObject[search_i_ShortDescription] = $row["ShortDescription"]; $SearchObject[search_i_FullDescription] = $row["FullDescription"]; $SearchObject[search_i_SmallImage] = $row["SmallImage"]; $SearchObject[search_i_Image] = $row["Image"]; $SearchObject[search_i_Available] = $row["Available"]; $SearchObject[search_i_Category] = $row["CategoryID"]; } else { // dep("No more searchobjects..."); } return($SearchObject); } function IsLastSearchObject( &$SearchObject ) { if (count($SearchObject[search_i_Row])>1) { return false; } else { return true; } } function GetNextSearchObject( &$SearchObject ) { $SearchObject[search_i_Row] = mysql_fetch_array( $SearchObject[search_i_ResultSet] ); return (GetSearchObject($SearchObject)); } function getSearchJoker () { return ("%"); } function GetFirstSearchObject( $queryText, $searchName, $searchDesc, $searchCode, $searchExtend = "X") { global $Session; $queryText = str_replace("'", "''", $queryText); $searchWhere = "("; $searchWordsArray = preg_split("/ +/", $queryText); // print "
"; print_r($searchWordsArray); print "
"; // for each word entered in the query field put the query together... foreach ($searchWordsArray as $queryText){ if (strlen($queryText) > 0){ if ($searchName=="X") { if ($searchWhere<>"(") { $searchWhere = $searchWhere . " OR "; } $searchWhere = $searchWhere . "(Products.Name LIKE '" . getSearchJoker() . $queryText . getSearchJoker() . "') "; $searchWhere = $searchWhere . " OR "; $searchWhere = $searchWhere . " (CustomfieldsAndProducts.Value LIKE '" . getSearchJoker() . $queryText . getSearchJoker() . "') "; } if ($searchDesc=="X") { if ($searchWhere<>"(") { $searchWhere = $searchWhere . " OR "; } $searchWhere = $searchWhere . " (Products.ShortDescription LIKE '" . getSearchJoker() . $queryText . getSearchJoker() . "') "; $searchWhere = $searchWhere . " OR (Products.FullDescription LIKE '" . getSearchJoker() . $queryText . getSearchJoker() . "') "; } if ($searchCode=="X") { if ($searchWhere<>"(") { $searchWhere = $searchWhere . " OR "; } $searchWhere = $searchWhere . " (Products.Code LIKE '" . getSearchJoker() . $queryText . getSearchJoker() . "') "; } // search within the product custom field if ($searchExtend=="X") { if ($searchWhere<>"(") { # $searchWhere = $searchWhere . " OR "; } # $searchWhere = $searchWhere . " (CustomfieldsAndProducts.Value LIKE '" . getSearchJoker() . $queryText . getSearchJoker() . "') "; } // end extended search } } // end the loop $searchWhere = $searchWhere . ")"; // print $searchWhere; $sql = "SELECT DISTINCT " . "Products.ProductID as Nr, " . "Products.Name, " . "cchMinMaxProductPrices.MinPrice, " . "cchMinMaxProductPrices.MaxPrice, " . "Products.ShortDescription, " . "Products.SmallImage, " . "Products.Image, " . "Products.Code, " . "Products.Inactive, " . "Products.PricePresentationID, " . "Products.FullDescription, " . "Products.Available " . # "FROM Products, cchMinMaxProductPrices " . "FROM Products, cchMinMaxProductPrices, CustomfieldsAndProducts, ProductCustomfields " . "WHERE Products.ProductID = cchMinMaxProductPrices.ProductID " . "and cchMinMaxProductPrices.CurrencyID = " . $Session["CurrencyID"] . " " . "and cchMinMaxProductPrices.PriceGroupId = " . $Session["PriceGroupID"] . " " . "and Products.Inactive = 0 " . "and Products.DeleteStatus = 0 " . "and Products.ProductID = CustomfieldsAndProducts.ProductID " . "and CustomfieldsAndProducts.CustomfieldID = ProductCustomfields.CustomfieldID ". # "and ProductCustomfields.DeleteStatus = 0 " . # "and CustomfieldsAndProducts.DeleteStatus = 0 " . "and " . $searchWhere . " " . "ORDER BY Products.Name"; $SearchObject[search_i_ResultSet] = mysql_query( $sql ); $SearchObject[search_i_Row] = mysql_fetch_array( $SearchObject[search_i_ResultSet] ); return(GetSearchObject($SearchObject)); } // ******************************************************************* // URL functions // ******************************************************************* function URLGetNextPageArg() { global $Session; return ("NextPage=" . urlencode( $Session["strCurrentPage"])); } function URLSetCurrent( $strURL ) { global $Session; $Session["strCurrentPage"] = $strURL; } function URLGetCurrent() { global $Session; return($Session["strCurrentPage"]); } function URLGetCurrentPath() { global $MY_PATH_INFO; return($MY_PATH_INFO); } function URLAppendArg( $strURL, $strArg ) { if (is_int(strpos( $strURL, "?" ))) { return($strURL . "&" . $strArg); } else { return($strURL . "?" . $strArg); } } function URLAppendArg2( $strURL, $strArg, $strArg2 ) { if (is_int(strpos( $strURL, "?" ))) { return($strURL . "&" . $strArg . "&" . $strArg2); } else { return($strURL . "?" . $strArg . "&" . $strArg2); } } function URLAppendArg3( $strURL, $strArg, $strArg2, $strArg3 ) { if (is_int(strpos( $strURL, "?" ))) { return($strURL . "&" . $strArg . "&" . $strArg2 . "&" . $strArg3); } else { return($strURL . "?" . $strArg . "&" . $strArg2 . "&" . $strArg3); } } function URLAppendArg4( $strURL, $strArg, $strArg2, $strArg3, $strArg4 ) { if (is_int(strpos( $strURL, "?" ))) { return($strURL . "&" . $strArg . "&" . $strArg2 . "&" . $strArg3 . "&" . $strArg4); } else { return($strURL . "?" . $strArg . "&" . $strArg2 . "&" . $strArg3 . "&" . $strArg4); } } function URLAppendArg5( $strURL, $strArg, $strArg2, $strArg3, $strArg4, $strArg5 ) { if (is_int(strpos( $strURL, "?" ))) { return($strURL . "&" . $strArg . "&" . $strArg2 . "&" . $strArg3 . "&" . $strArg4 . "&" . $strArg5); } else { return($strURL . "?" . $$strArg . "&" . $strArg2 . "&" . $strArg3 . "&" . $strArg4 . "&" . $strArg5); } } function URLAppendArg6( $strURL, $strArg, $strArg2, $strArg3, $strArg4, $strArg5, $strArg6 ) { if (is_int(strpos( $strURL, "?" ))) { return($strURL . "&" . $strArg . "&" . $strArg2 . "&" . $strArg3 . "&" . $strArg4 . "&" . $strArg5 . "&" . $strArg6); } else { return($strURL . "?" . $strArg . "&" . $strArg2 . "&" . $strArg3 . "&" . $strArg4 . "&" . $strArg5 . "&" . $strArg6); } } //******************************************************************* // GetLink functions //******************************************************************* //Currencies function URLGetLinkPageCurrencies() { return(URLAppendArg("Currencies.php", URLGetNextPageArg())); } //AddProduct( strID, blnVariantCategory ) function URLGetLinkPageAddProduct( $strID, $blnVariantCategory ) { if ($blnVariantCategory == true) { return(URLAppendArg2( "AddProduct.php", "CategoryID=" . $strID, URLGetNextPageArg())); } else { return(URLAppendArg2( "AddProduct.php", "ProductID=" . $strID, URLGetNextPageArg())); } } function URLGetLinkPageAddProductWithNextPage( $strID, $blnVariantCategory, $strNextPage ) { if ($blnVariantCategory == true) { return(URLAppendArg2( "AddProduct.php", "CategoryID=" . $strID, "NextPage=" . URLEncode( $strNextPage ))); } else { return(URLAppendArg2( "AddProduct.php", "ProductID=" . $strID, "NextPage=" . URLEncode( $strNextPage ))); } } //Tree( strID, strSP, strPPP ) function URLGetLinkPageTree( $strID, $strSP, $strPPP ) { if ($strID == -1) { return(URLAppendArg2( "ProductTree.php", "PPP=" . $strPPP, "SP=" . $strSP )); } else { return(URLAppendArg3( "ProductTree.php", "CategoryID=" . $strID, "PPP=" . $strPPP, "SP=" . $strSP )); } } //Detail( strID, blnVariantCategory ) function URLGetLinkPageDetail( $strID, $blnVariantCategory ) { if ($blnVariantCategory == true) { return(URLAppendArg2( "ProductDetail.php", "CategoryID=" . $strID, URLGetNextPageArg())); } else { return(URLAppendArg2( "ProductDetail.php", "ProductID=" . $strID, URLGetNextPageArg())); } } //List( strSP, strPPP ) function URLGetLinkPageList( $strSP, $strPPP ) { return(URLAppendArg2( "ProductList.php", "PPP=" . $strPPP, "SP=" . $strSP )); } //Search( blnReload, blnName, blnDescription, blnCode, strSP, strPPP ) function URLGetLinkPageSearch( $strReload, $strName, $strDescription, $strCode, $strSP, $strPPP ) { return(URLAppendArg6( "Search.php", "reload=" . $strReload, "Name=" . $strName, "Description=" . $strDescription, "pCode=" . $strCode, "PPP=" . $strPPP, "SP=" . $strSP )); } function str_replace_i( $needle, $str, $haystack ) { $res = ""; $needle = strtoupper( $needle ); $pos = strpos( strtoupper( $haystack ), $needle); while( is_int( $pos )) { // echo "#REPLACE: " . $needle . " wird durch " . $str . " ersetzt in " . $haystack . "
"; if( $pos > 0 ) { $res = $res . substr( $haystack, 0, $pos ) . $str; } else { $res = $res . $str; } $haystack = substr( $haystack, $pos + strlen( $needle )); $pos = strpos( strtoupper( $haystack ), $needle ); } $res = $res . $haystack; return( $res ); } function mystrcmp( $s, $t ) { if( $s && $t ) return strcmp( $s, $t); else return -strcmp( $s, $t); } function GetMaxDiscountFromCategory( $CategoryID ) { global $Session; $sql = "SELECT Promotions.Discount " . "FROM Products " . "LEFT JOIN Promotions ON Products.ProductID = Promotions.ProductID " . "WHERE Products.CategoryID=" . $CategoryID . " " . "AND " . $Session[ "strCustomerCategories" ] . "AND Promotions.BeginDate<=" . SQLDate() . " AND Promotions.EndDate>=" . SQLDate() . " " . "AND Products.Inactive=0 " . "AND Promotions.DeleteStatus=0 " . "AND Products.DeleteStatus=0 " . "ORDER BY Promotions.Discount DESC " . "LIMIT 1 "; //dep( $sql ); $rs = mysql_query( $sql ); if( $row = mysql_fetch_array( $rs )) { $res = $row[ "Discount" ]; mysql_free_result( $rs ); //dep( $res ); return( $res ); } else { return 0; } } function GetMaxDiscount( $ProductID ) { global $Session; $sql ="SELECT " . "Promotions.Discount " . "FROM Promotions LEFT JOIN Products ON Products.ProductID = Promotions.ProductID " . "WHERE " . "Promotions.DeleteStatus=0 " . "AND " . $Session[ "strCustomerCategories" ] . "AND Promotions.BeginDate<=" . SQLDate() . " AND Promotions.EndDate>=" . SQLDate() . " " . "AND Promotions.ProductID=" . $ProductID . " " . "AND Promotions.JoinedProductID is null " . "ORDER BY Promotions.Discount DESC"; $rs = mysql_query( $sql ); if( $row = mysql_fetch_array( $rs )) { $res = $row[ "Discount" ]; mysql_free_result( $rs ); return( $res ); } else { return 0; } } function Jump($page ) { Session_Save(); Header( "Location: " . $page ); Exit; } function WebEncode( $str ) { return( htmlentities( $str )); } function WebEncodeDesc( $str ) { return( nl2br( $str )); } function SetWPCookie( $str ) { setCookie("webPiazzaShopPHP", $str, time()+3600 ); } function DeleteWPCookie() { SetCookie("webPiazzaShopPHP"); } function CheckPassword($text) { if( strstr( $text, "&" ) > 0 OR strstr( $text, "#" ) > 0 OR strstr( $text, "%" ) > 0 OR strstr( $text, "$" ) > 0 ) return( true ); elseif( strstr( $text, "!" ) > 0 OR strstr( $text, "-" ) > 0 OR strstr( $text, "+" ) > 0 OR strstr( $text, "*" ) > 0 ) return( true ); elseif( strstr( $text, "." ) > 0 OR strstr( $text, "," ) > 0 OR strstr( $text, ":" ) > 0 OR strstr( $text, ";" ) > 0 ) return( true ); elseif( strstr( $text, "1" ) > 0 OR strstr( $text, "2" ) > 0 OR strstr( $text, "3" ) > 0 OR strstr( $text, "4" ) > 0 ) return( true ); elseif( strstr( $text, "5" ) > 0 OR strstr( $text, "6" ) > 0 OR strstr( $text, "7" ) > 0 OR strstr( $text, "8" ) > 0 ) return( true ); elseif( strstr( $text, "9" ) > 0 OR strstr( $text, "0" ) > 0 ) return( true ); else return( false ); } function SQLDate() { return "'" . date( "Y-m-d" ) . "'"; } function SQLDateAndTime() { return "'" . date( "Y-m-d" ) . " " . date( "H:i:s" ) . "'"; } function GetCODCost( $intTariffID ) { return( 0 ); } function GetRandomString( $digits ) { mt_srand((double)microtime()*1000000); if( $digits > 9 ) { if( $digits % 2 == 0 ) { return GetRandomString( $digits / 2 ) . GetRandomString( $digits / 2 ); } else { return GetRandomString(( $digits - 1 ) / 2 ) . GetRandomString(( $digits - 1 ) / 2 + 1); } } else { $num = sprintf( "%0" . $digits . "d", mt_rand()); if( strlen( $num ) > $digits ) { $num = substr( $num, 0, $digits ); } return $num; } } function CSQLDouble( $value ) { $res = str_replace( ",", ".", $value ); if( is_int( $res )) { $res = $res . ".0"; } return $res; } function CSQLString( $value ) { return str_replace( "'", "''", $value ); } //************************************************************** // debug functions //************************************************************** function dep( $str ) { echo "[DEP] " . $str . "
"; } function GetUnitSymbol( $lngProductID ) { if ($lngProductID > 0) { $strSQL = "SELECT ProductUnits.Symbol FROM ProductUnits LEFT JOIN Products ON ProductUnits.UnitID = Products.UnitID WHERE Products.ProductID=" . $lngProductID; //dep("strSQL: " . $strSQL); $rsUnit = mysql_query( $strSQL ); if( $row = mysql_fetch_array( $rsUnit )) { return $row[ "Symbol" ]; } else { return ""; } } else return("Error"); } function GetAsSSLPage( $strPage ) { global $SERVER_NAME, $PHP_SELF; $currentPath = $PHP_SELF; $url = "https://" . $SERVER_NAME . substr($currentPath,0, strrpos($currentPath, "/")+1) . $strPage; return($url); } function GetAsNoSSLPage( $strPage ) { global $SERVER_NAME, $PHP_SELF; $currentPath = $PHP_SELF; $url = "http://" . $SERVER_NAME . substr($currentPath,0, strrpos($currentPath, "/")+1) . $strPage; return($url); } function GetPriceGroupIDString($lngPriceGroupID) { $strSQL = "SELECT PriceGroups.IDString FROM PriceGroups WHERE PriceGroupID=" . $lngPriceGroupID; $rsPriceGroup = mysql_query( $strSQL ); if( $row = mysql_fetch_array( $rsPriceGroup )) { return($row["IDString"]); } else { dep("Fatal Error: No valid pricegroupid"); } } function GetDefaultPriceGroupID() { $strSQL = "SELECT PriceGroupID FROM PriceGroups WHERE Active=1 ORDER BY IDString"; $rsPriceGroup = mysql_query( $strSQL ); if( $row = mysql_fetch_array( $rsPriceGroup )) { return($row["PriceGroupID"]); } else { dep("Error: No default pricegroup defined."); } } function hasAccessToDetail($lngCustomerID, $intCustomerDB) { $blnAccess = 0; $strSQL = "SELECT CustomerCategories.AccessToDetails, CustomerCategoriesAndCustomers.CustomerID, CustomerCategoriesAndCustomers.CustomerDB " . "FROM CustomerCategories LEFT JOIN CustomerCategoriesAndCustomers ON CustomerCategories.CategoryID = CustomerCategoriesAndCustomers.CategoryID " . "WHERE CustomerCategoriesAndCustomers.CustomerID=" . $lngCustomerID . " AND CustomerCategoriesAndCustomers.CustomerDB=" . $intCustomerDB; $rsAccess = mysql_query( $strSQL ); while( $row = mysql_fetch_array( $rsAccess )) { if ($row["AccessToDetails"]) { $blnAccess = 1; break; } } return($blnAccess); } function query_string() { global $HTTP_GET_VARS; reset($HTTP_GET_VARS); while(list($k,$v) = each($HTTP_GET_VARS)) { if(isset($q_arr[$k])) continue; { if($k=="NextPage") { $str .= "$k=" . urlencode($v) . "&"; } else { $str .= "$k=$v&"; } } } return $str; } function JumpToPriceGroupPage() { global $Session, $PHP_SELF; $strPage = $PHP_SELF; $intPos = strpos($strPage, "."); $PageNumber = (int) substr($strPage, $intPos - 1,1); if (is_int($PageNumber)) { $intPos = (int) $PageNumber; } else { $intPos = (int) 0; } $intPGID = (int) GetPriceGroupIDString($Session["PriceGroupID"]); if ($intPGID <> $intPos) { if ($intPGID == 0) { $intPGID = ""; } $intPos = strpos($strPage, "/",2); $strPage = substr($strPage, $intPos, strlen($strPage)-$intPos); $intPos = strpos($strPage, "."); $strPage = substr($strPage, 1, $intPos-1); $strQueryString = query_string(); if ($strQueryString <> "") { $strQueryString = "?" . $strQueryString; } $strPage = $strPage . $intPGID . ".php" . $strQueryString; //dep ($strPage); //dep ("Link"); Jump($strPage); } } function BooleanToInt($strValue) { if(strtoupper($strValue) == "TRUE") return(1); else return(0); } //************************************************************************** // Online Tax Calculation (OTC) functions //************************************************************************** function OTCCalculate( $strProdCat ) { // return the multiplier (0.08% = 1.08) computed by active OTC system global $Session; $strOTCProvider = $Session[ "OTCProvider" ]; $strError = "Fatal error: Online Tax Calculation failed!"; $strLine = ""; if ( $strOTCProvider == "STC" ) { // ff2: if ( $Session[ "shp_address" ] == false ) if ( !$Session[ "shp_address" ] ) $CurrentZIPCode = $Session[ "OTCZIPCode" ]; else $CurrentZIPCode = $Session[ "ShpZIPCode" ]; if ( strlen($Session[ "OTCTax" . $strProdCat . "_" . $CurrentZIPCode ]) == 0 ) { $rate = -1; $lngErrorLevel = error_reporting(); error_reporting(0); $file = fopen( $Session[ "OTCUrl" ] . "&ProdCat=" . $strProdCat . "&ZIP=" . $CurrentZIPCode, "r" ); error_reporting($lngErrorLevel); if ($file) { if (!feof($file)) { $strLine = fgets($file, 1024); if ( substr ($strLine, 0, 3) != "ERR" ) { $tok = strtok ($strLine,"%"); if ($tok) { $rate = (1 + $tok/100); $Session[ "OTCTax" . $strProdCat . "_" . $CurrentZIPCode ] = $strLine; } } } fclose($file); } } else { $tok = strtok ($Session[ "OTCTax" . $strProdCat . "_" . $CurrentZIPCode ], "%"); if ($tok) $rate = (1 + $tok/100); $strLine = $Session[ "OTCTax" . $strProdCat . "_" . $CurrentZIPCode ]; } } else { // perhaps other OTC providers ... $rate = -1; } if ( $rate == -1) { dep ( $strError . " " . $strOTCProvider . " " .$strLine ); } /* else { dep ( $strOTCProvider . " " .$strLine . " TaxCategory: " . $strProdCat ); } */ return $rate; } function OTCEnabled() { // return IDString of the "ready to work" OTC system global $Session; // ff2: initialize OTCProvider if (!isset($Session[ "OTCProvider" ])) $Session[ "OTCProvider" ]=''; if ( strlen( $Session[ "OTCProvider" ] ) != 0 ) { if ( $Session[ "OTCProvider" ] == "STC" ) { // ff2: if ( $Session[ "shp_address" ] == false ) if ( !$Session[ "shp_address" ] ) { if( strlen( $Session[ "Code" ] ) != 0 AND $Session[ "OTCCountry" ] == "USA" AND strlen( $Session[ "OTCUrl" ] ) != 0 AND strlen( $Session[ "OTCZIPCode" ] ) != 0) return ("STC"); else return (""); } else { if( strlen( $Session[ "Code" ] ) != 0 AND $Session[ "ShpCountry" ] == "USA" AND strlen( $Session[ "OTCUrl" ] ) != 0 AND strlen( $Session[ "ShpZIPCode" ] ) != 0) return ("STC"); else return (""); } } else { // perhaps other OTC providers ... return (""); } } else { return (""); } } function OTCInit() { // initialize session variables for OTC provider and customer data global $Session; if ( GetMiscDBValue("OTCEnabled","") == "1" ) // OTC system enabled { if ( GetMiscDBValue("OTCProvider","") == "STC" ) { // init STC Provider data $Session[ "OTCProvider" ] = "STC"; $strUrl = GetMiscDBValue("STCUrl",""); $strMid = GetMiscDBValue("STCMerchantID",""); $strPwd = GetMiscDBValue("STCPwd",""); if ( strlen( $strUrl ) != 0 AND strlen( $strMid ) != 0 ) { $Session[ "OTCUrl" ] = $strUrl . "?V1&MID=" . $strMid . "&Pwd=" . $strPwd; } else { $Session[ "OTCUrl" ] = ""; } //init STC required Customer data if ( strlen($Session [ "Code" ]) != 0 ) { $strSQL = "SELECT ShpZIPCode, " . "IDString FROM Customers, Countries WHERE Customers.ShpCountryID=Countries.CountryID AND Customers.Code='" . $Session [ "Code" ] . "' AND Customers.DeleteStatus=0"; $rsCheck = mysql_query( $strSQL ); if( $row = mysql_fetch_array( $rsCheck )) { //dep ($row[ "ShpZIPCode" ] . " " . $row[ "IDString" ]); $Session[ "OTCZIPCode" ] = $row[ "ShpZIPCode" ]; $Session[ "OTCCountry" ] = $row[ "IDString" ]; } mysql_free_result( $rsCheck ); } } else { // perhaps other OTC provider ... } } } function GetOTCMultiplier ($ProductID) { // central function to get a multiplier from the active OTC system, // returns -1, if prices like being normally calculated should (e.g. // no OTC system is active, errors occured during connection to OTC // provider, OTC paramerters are not completely) $strOTCProvider = OTCEnabled(); if( strlen($strOTCProvider) != 0 ) { return ( OTCCalculate( GetProductTaxCategory ( $ProductID ) ) ); } else { return (-1); } } function GetFormatedOTCString ($ProductID) { // return string, which is used in the productdetails to show the // constituents of VAT global $Session; $strFormatedTaxString = ""; if ( strlen (OTCEnabled()) != 0 ) { if ($Session[ "OTCProvider" ] == "STC") { // ff2: if ( !$Session[ "shp_address" ] ) if ( $Session[ "shp_address" ] == false ) $CurrentZIPCode = $Session[ "OTCZIPCode" ]; else $CurrentZIPCode = $Session[ "ShpZIPCode" ]; $strTaxString = $Session[ "OTCTax" . GetProductTaxCategory($ProductID) . "_" . $CurrentZIPCode ]; if ( strlen ( $strTaxString) == 0 ) { $strFormatedTaxString = ""; } else { $intCount = 1; $strFormatedTaxString = "Price incl. Tax "; $tok = strtok ($strTaxString, ","); while($tok) { if ( $intCount == 1) { $strFormatedTaxString = $strFormatedTaxString . $tok . " (calculated by stc)
"; } if ( $intCount == 2 OR $intCount == 4 OR $intCount == 6 OR $intCount == 8) { $strFormatedTaxString = $strFormatedTaxString . $tok . ", "; } if ( $intCount == 3 OR $intCount == 5 OR $intCount == 7) { $strFormatedTaxString = $strFormatedTaxString . $tok . " "; } if ( $intCount == 9) { $strFormatedTaxString = $strFormatedTaxString . "ZIPCode " . $tok; } $tok = strtok(","); $intCount++; } } } else { // perhaps other OTC provider ... } } return ($strFormatedTaxString); } function GetByCountryID ($intCountryID, $strColumn) { // return value of field of table Countries $IDString = ""; $strSQL = "SELECT " . $strColumn . " FROM Countries WHERE CountryID=" . $intCountryID; $rsCheck = mysql_query( $strSQL ); if( $row = mysql_fetch_array( $rsCheck )) { $IDString = $row[$strColumn]; } mysql_free_result( $rsCheck ); return ($IDString); } function GetMiscDBValue ($strKey, $strPath) { // return value from table Miscellaneous if ( strlen($strPath) == 0 ) { $strSQL = "SELECT Value FROM Miscellaneous WHERE Name = '" . $strKey . "' AND Parent is Null AND NOT (Value is Null) AND DeleteStatus=0"; $rsAccess = mysql_query( $strSQL ); if ($row = mysql_fetch_array( $rsAccess)) { return ($row["Value"]); } else { return (""); } mysql_free_result($rsAccess); } else { $strRestPath = $strPath; if ( substr($strRestPath,-1) != "\\") { $strRestPath = $strRestPath . "\\"; } $bPathNotDefined = false; $nLastID = -1; $tok = strtok ($strRestPath, "\\"); while ( $tok ) { if ($nLastID == -1) { $strSQL = "SELECT * FROM Miscellaneous WHERE Name = '" . $tok . "' AND DeleteStatus=0"; } else { $strSQL = "SELECT * FROM Miscellaneous WHERE Name = '" . $tok . "' AND Parent=" .$nLastID . " AND DeleteStatus=0"; } $rsAccess = mysql_query( $strSQL ); if ($row = mysql_fetch_array( $rsAccess)) { $nLastID = $row["ID"]; } else { $bPathNotDefined = true; } mysql_free_result($rsAccess); $tok = strtok("\\"); } if (!$bPathNotDefined) { $strSQL = "SELECT * FROM Miscellaneous WHERE Name = '" . $strKey . "' AND Not (Value Is Null) AND Parent=" .$nLastID . " AND DeleteStatus=0"; $rsAccess = mysql_query( $strSQL ); if ($row = mysql_fetch_array( $rsAccess)) { return ($row["Value"]); } else { return (""); } mysql_free_result($rsAccess); } } } function GetProductTaxCategory ($ProductID) { // return the OTC TaxCategory of a product $strSQL = "SELECT TaxCategory FROM Products WHERE NOT (TaxCategory is Null) AND ProductID = " . $ProductID; $rsAccess = mysql_query( $strSQL ); if ($row = mysql_fetch_array( $rsAccess)) $intProdCat = $row["TaxCategory"]; else $intProdCat = 0; // default value mysql_free_result($rsAccess); return ($intProdCat); } //************************************************************************** // Online Shipping Cost Calculation (OSC) functions //************************************************************************** function OSCInit ($intTariffID) { // initialize session variable of active OSC providers global $Session; $currentPath = "OSCServices\\OSCService_" . $intTariffID; $strOSCType = GetMiscDBValue("OSCType",$currentPath); if ($strOSCType == "GoShip") { $Session[ "OSCType_" . $intTariffID ] = $strOSCType; $Session[ "OSCUrl_" . $intTariffID ] = GetMiscDBValue("Url",$currentPath); $Session[ "OSCCubeID_" . $intTariffID ] = GetMiscDBValue("CubeID",$currentPath); $Session[ "OSCClientID_" . $intTariffID ] = GetMiscDBValue("ClientID",$currentPath); $Session[ "OSCOriginCountry_" . $intTariffID ] = GetMiscDBValue("OriginCountry",$currentPath); $Session[ "OSCOriginZIP_" . $intTariffID ] = GetMiscDBValue("OriginZIP",$currentPath); $Session[ "OSCFullFillmentDelay_" . $intTariffID ] = GetMiscDBValue("FullFillmentDelay",$currentPath); if ( $Session[ "shp_address" ] ) { $Session[ "OSCZIPCode" ] = $Session[ "ShpZIPCode" ]; $Session[ "OSCCountry" ] = GetByCountryID( $Session[ "ShpCountryID" ], "OSCIDString"); } else { $strSQL = "SELECT ShpZIPCode, OSCIDString FROM Customers, Countries WHERE " . "Customers.ShpCountryID=Countries.CountryID AND Code=" . $Session [ "Code" ]; $rsAccess = mysql_query( $strSQL ); if ($row = mysql_fetch_array( $rsAccess)) { $Session[ "OSCZIPCode" ] = $row[ "ShpZIPCode" ]; $Session[ "OSCCountry" ] = $row[ "OSCIDString" ];; } mysql_free_result($rsAccess); } } else { // maybe other OSC provider ... } } function GetAvailableShippingServices ($intTariffID) { // create request string, request OSC provider // write available carrier services of a OSC provider in a // session array (via function OSCResponse2Session) global $Session, $SESSION_ID; $Cart = $Session[ "Cart" ]; if ($Session[ "OSCType_" . $intTariffID ] == "GoShip") { $strRequest = $Session[ "OSCUrl_" . $intTariffID ] . "?&gs_mode=rate&gs_return_specials=true" . "&gs_client=" . $Session[ "OSCClientID_" . $intTariffID ] . "&gs_session=" . $SESSION_ID . "&gs_order=1&gs_service=LOWEST&gs_item_count=" . $Session[ "CartCount" ]; for( $i = 0; $i <= $Session[ "CartCount" ]-1; $i++ ) { $strRequest = $strRequest . "&gs_ratecube_" . $i . "=" . $Session[ "OSCCubeID_" . $intTariffID ] . "&gs_origin_country_" . $i . "=" . $Session[ "OSCOriginCountry_" . $intTariffID ] . "&gs_origin_" . $i . "=" . $Session[ "OSCOriginZIP_" . $intTariffID ] . "&gs_dest_country_" . $i . "=" . $Session[ "OSCCountry" ] . "&gs_dest_" . $i . "=" . $Session[ "OSCZIPCode" ]; $strSQL = "SELECT Weight, Length, Height, Width FROM Products WHERE ProductID=" . $Cart[ cart_i_ProductID ][ $i+1 ]; $rsAccess = mysql_query( $strSQL ); if ($row = mysql_fetch_array( $rsAccess)) { $dblLength = $row["Length"]; $dblHeight = $row["Height"]; $dblWidth = $row["Width"]; if ( $dblLength < $dblWidth ) { $temp = $dblLength; $dblLength = $dblWidth; $dblWidth = $temp; } if ( $dblLength < $dblHeight ) { $temp = $dblLength; $dblLength = $dblHeight; $dblHeight = $temp; } if ( $dblLength<1 ){ $dblLength=1; } if ( $dblHeight<1 ){ $dblHeight=1; } if ( $dblWidth<1 ){ $dblWidth=1; } $WeightInPounds = $row["Weight"]/453.592; $strRequest = $strRequest . "&gs_weight_" . $i . "=" . $WeightInPounds . "&gs_length_" . $i . "=" . $dblLength . "&gs_height_" . $i . "=" . $dblHeight . "&gs_width_" . $i . "=" . $dblWidth; } mysql_free_result($rsAccess); $strRequest = $strRequest . "&gs_delay_" . $i . "=" . $Session[ "OSCFullFillmentDelay_" . $intTariffID ] . "&gs_quantity_" . $i . "=" . $Cart[ cart_i_Quantity ][ $i+1 ] . "&gs_value_" . $i . "=" . OSCCurrencyCalculator($Cart[ cart_i_Price][ $i+1 ], "", "USD"); } $lngErrorLevel = error_reporting(); error_reporting(0); $file = fopen( $strRequest, "r" ); error_reporting($lngErrorLevel); if ($file) { if (!feof($file)) { $strLine = ""; while ($buffer = fgets($file, 1024)) { $strLine = $strLine . $buffer; } } fclose($file); if ( $strLine != "" ) { //dep($strLine); OSCResponse2Session( $strLine ); } } } else { // maybe other OSC provider } } function OSCResponse2Session ( $strLine ) { // sub procedure of GetAvailableShippingServices // write from OSC response string available carrier services of a // OSC provider in a session array global $Session; //$Session["OSCResultString"]= $strLine; $aPieces = explode("|", $strLine); for ( $i=0; $i" . $Session[ "OSCType_" . $TariffID] . ""; $strLink = "Rates Powered By " . $strLink . " - "; } else { // maybe other OSCProviders } return ($strLink); } %>
Fatal error: Call to undefined function: booleantoint() in /home/stockerverlag/home/shop/ProductDetail.php on line 5