name][$el] = ""; } return $empty_obj; } //-------------------------------------------------------------------------------------- public static function getProductOptions($parent_id = NULL, $start_num = NULL, $end_num = NULL, $striphtml = NULL) { //set the result array members (query returned fields) $dbVars = array( 'id', 'ProductID', 'Name', 'Image1', 'Code', 'Colour' ); //retrieve the list of items in this category, including their current grouping order $query = ' SELECT * ' . ' FROM tentacle_ProductOptions ' . ' WHERE (' . ' (tentacle_ProductOptions.`DateDeleted` IS NULL) ' . ' AND ' . ' (tentacle_ProductOptions.`Active` = 1) ' . ' AND ' . ' (tentacle_ProductOptions.`Qty` > 0) '; if($parent_id !== NULL) { $query .= ' AND (tentacle_ProductOptions.`ProductID` = ' . $parent_id . ') '; } $query .= ' ) ' . ' ORDER BY tentacle_ProductOptions.`DisplayOrder` '; if(($start_num !== NULL) && ($end_num !== NULL)) { $query .= ' LIMIT ' . $start_num . ',' . $end_num; } $result = mysql_query($query) or display_error(mysql_error() . "\n" . $query, __LINE__, __FILE__); //return the data as an array $data = array(); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $db_row = array(); foreach($dbVars as $var) { if($row[$var] === NULL || $row[$var] == "") { $db_row[$var] = NULL; } else { //by default we return html friendly text - except any image field, since filenames can have $'s in them if ($striphtml !== NULL) { $db_row[$var] = $row[$var]; } else { $db_row[$var] = htmlspecialchars($row[$var]); } } } array_push($data, $db_row); } return $data; } //-------------------------------------------------------------------------------------- public static function getProductOptionsQty($parent_id = NULL) { //retrieve the list of items in this category, including their current grouping order $query = ' SELECT * ' . ' FROM tentacle_ProductOptions ' . ' WHERE (' . ' (tentacle_ProductOptions.`DateDeleted` IS NULL) ' . ' AND ' . ' (tentacle_ProductOptions.`Active` = 1) ' . ' AND (tentacle_ProductOptions.`ProductID` = ' . $parent_id . ')) '; $result = mysql_query($query) or display_error(mysql_error() . "\n" . $query, __LINE__, __FILE__); $total = 0; while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $total = $total + $row['Qty']; } return $total; } //-------------------------------------------------------------------------------------- public static function updateProductOptionsQty($option_id = NULL, $qty = NULL) { $query = ' UPDATE tentacle_ProductOptions ' . ' SET ' . ' Qty = Qty - ' . $qty . ' WHERE ' . ' id = ' . $option_id; $result = mysql_query($query) or display_error(mysql_error() . "\n" . $query, __LINE__, __FILE__); } // ------------------------------------------------------------------------------------------------ public static function getProductOptionDetails($productoption_id = NULL) { if($productoption_id !== NULL) { //retrieve the product & size info $dbVars = array( 'id', 'Name', 'Code', 'Colour' ); $query = " SELECT * "; $query .= " FROM `tentacle_ProductOptions`"; $query .= " WHERE"; $query .= " (`tentacle_ProductOptions`.`id` = " . $productoption_id . ")"; $result = mysql_query($query) or display_error(mysql_error() . "\n" . $query, __LINE__, __FILE__); $result = mysql_fetch_array($result, MYSQL_ASSOC); return $result; } } //-------------------------------------------------------------------------------------- public static function updateDisplayOrder($id = NULL, $order = NULL) { $query = ' UPDATE tentacle_ProductOptions ' . ' SET ' . ' DisplayOrder = ' . $order . ' WHERE ' . ' id = ' . $id; $result = mysql_query($query) or display_error(mysql_error() . "\n" . $query, __LINE__, __FILE__); } //-------------------------------------------------------------------------------------- public static function getMaxDisplayOrder($parent_id = NULL) { //retrieve the list of items $query = ' SELECT MAX(tentacle_ProductOptions.DisplayOrder) AS DisplayOrder' . ' FROM tentacle_ProductOptions ' . ' WHERE (DateDeleted IS NULL) ' . ' AND (ProductID = ' . $parent_id . ')'; $result = mysql_query($query) or display_error(mysql_error() . "\n" . $query, __LINE__, __FILE__); $result = mysql_fetch_array($result, MYSQL_ASSOC); return $result['DisplayOrder']; } //------------------------------------------------------------------------------------ public static function getCountByProduct($parent_id) { //retrieve the list of items $query = ' SELECT COUNT(tentacle_ProductOptions.id) AS TotalCount' . ' FROM tentacle_ProductOptions ' . ' WHERE (DateDeleted IS NULL) ' . ' AND (ProductID = ' . $parent_id . ')'; $result = mysql_query($query) or display_error(mysql_error() . "\n" . $query, __LINE__, __FILE__); $result = mysql_fetch_array($result, MYSQL_ASSOC); return $result['TotalCount']; } } ?> name][$el] = ""; } return $empty_obj; } //--------------------------------------------------------------------------------- public static function getHomebanners($limit = NULL) { //set the result array members (query returned fields) $dbVars = array( 'id', 'Name', 'Link', 'Image1' ); //retrieve the list of items in this category, including their current grouping order $query = " SELECT `tentacle_Homebanners`.* "; $query .= " FROM `tentacle_Homebanners`"; $query .= " WHERE (`tentacle_Homebanners`.`Active` = 1) "; $query .= " AND (`tentacle_Homebanners`.`DateDeleted` IS NULL) "; $query .= " ORDER BY RAND()"; if($limit !== NULL) { $query .= " LIMIT " . $limit; } $result = mysql_query($query) or display_error(mysql_error() . "\n" . $query, __LINE__, __FILE__); //return the data as an array $data = array(); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $db_row = array(); foreach($dbVars as $var) { if($row[$var] === NULL || $row[$var] == "") { $db_row[$var] = NULL; } else { //by default we return html friendly text - except any image field, since filenames can have $'s in them if ($striphtml !== NULL) { $db_row[$var] = $row[$var]; } else { $db_row[$var] = htmlspecialchars($row[$var]); } } } array_push($data, $db_row); } return $data; } } ?>