%
//********************************************************************
// 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 . "