color_info(name, hex, descrip, ais_web, ais_store, avail date) ( from inventory_item_colors var $web_colors; var $sizes; // array of sizes from size_scale_sizes (size_id=>size) var $web_sizes; var $size_scale_data; // array of size_scales table data - ie descrip, chart file (items.size_scale_id) var $web_images; // array of imageorder that have complete set of images (pointer to images) var $web_qty_max; var $web_qty_max_default = 9; var $categories; // array [itemcatid] => array(catid, catname); var $cross_sells; // array of cross sell item ids var $reason_off_web; var $swatchDivs; var $in_stock; // array of colors and sizes function __Construct($item_id=0) { $this->id = $item_id; } function set_in_stock() { // array of colors and sizes or just colors ?? what if no color or size ?? if(!isset($this->web_colors)) { $this->set_web_colors_and_sizes(); } foreach($this->web_colors as $item_color_id => $color_name) { if(count($this->web_sizes) > 0) { foreach($this->web_sizes as $size_id =>$size) { if($this->get_breakdown_qty_instock($item_color_id, $size_id) > 0) { $this->in_stock[$color_name][] = $size; } } } else { if($this->get_breakdown_qty_instock($item_color_id, 0) > 0) { $this->in_stock[$color_name] = TRUE; } } } } function set_data() { $sel = "SELECT * FROM ".Config::$db_tables['inventory_items']." WHERE id='".$this->id."'"; return($this->data = Database::ado_get_row($sel, "items::get_item_data")); } function set_season() { if(!isset($this->data)) { $this->set_data(); } if($this->data['season_id'] == 0) { $this->season == ''; } else { $this->season = Database::ado_get_one("SELECT season FROM ".Config::$db_tables['inventory_seasons']." WHERE id = ".$this->data['season_id']); } } function set_grouping() { if(!isset($this->data)) { $this->set_data(); } if($this->data['grouping_id'] == 0) { $this->grouping == ''; } else { if(!$this->grouping = Database::ado_get_one("SELECT title FROM ".Config::$db_tables['inventory_groupings']." WHERE id = ".$this->data['grouping_id']." AND status='active'")) { $this->grouping == ''; } } } function set_designer() { if(!isset($this->data)) { $this->set_data(); } $this->designer = Database::ado_get_one("SELECT name FROM ".Config::$db_tables['vendor_designers']." WHERE id = ".$this->data['designer_id']); } function get_data() { return($this->data); } function is_live_web($Items) { return($this->is_instock_web() && $this->has_web_images($Items)) ? TRUE : FALSE; } function has_web_images($Items) { if(!isset($this->web_images)) { $this->set_web_images($Items); } if(count($this->web_images) > 0) { return(TRUE); } else { $this->reason_off_web = 'no images'; return(FALSE); } } function get_on_sale($which) { if(!isset($this->{"on_sale_$which"})) { $this->set_on_sale($which); } return($this->{"on_sale_$which"}); } function get_on_promotion_web($Promotion) { if(!isset($this->on_promotion_web)) { $this->set_on_promotion_web($Promotion); } return($this->on_promotion_web); } function is_instock_web() { if(!isset($this->data)) { $this->set_data(); } if(!isset($this->breakdown)) { $this->set_breakdown(); } if(!isset($this->colors)) { $this->set_colors(); } // checks status, price and inventory if($this->data['status_web'] != 'active') { $this->reason_off_web = 'inactive status'; return(FALSE); } if($this->data['price_web'] == 0) { $this->reason_off_web = 'no web price'; return(FALSE); } // loop thru breakdown and if any are in stock return true foreach($this->breakdown as $bd_id => $bd_info) { if($bd_info['qty_instock'] > 0) { return(TRUE); } } // loop thru colors and if any are ais return true foreach($this->colors as $color_id => $color_info) { if($color_info['ais_web'] == 'yes') { return(TRUE); } } $this->reason_off_web = 'no web inventory'; return(FALSE); } function old__Construct($Items, $Sizes, $item_id, $item_type='existing', $set_all=TRUE) { // set_all = FALSE will save time during instantiation $this->data = array(); $this->images = array(); $this->breakdown = array(); $this->colors = array(); $this->web_colors = array(); $this->sizes = array(); $this->web_sizes = array(); $this->size_scale_data = array(); $this->web_images = array(); $this->categories = array(); $this->cross_sells = array(); if($item_type == 'existing') { if(!$this->set_data($item_id)) { $this->set_error(TRUE, 'item db record not found'); return(FALSE); } $this->set_designer_name($Designers); if($set_all) { $this->set_colors(); $this->sizes($Sizes); // sets this->size_scale_data and this->sizes $this->set_breakdown(); $this->set_web_colors_and_sizes(); $this->set_categories(); $this->set_images($Items);// multi dim w/ image file paths, caption, image width, height, type $this->set_web_images(); $this->set_cross_sells(); $this->set_on_sale('store'); $this->set_on_sale('web'); } } } function set_cross_sells() { // note doesn't check for item being live $this->cross_sells = array(); $RS = Database::ado_execute_query("SELECT * FROM ".Config::$db_tables['inventory_cross_sell']." WHERE item_id='$this->id'"); while($record = $RS->FetchRow()) { $this->cross_sells[] = $record['cross_item_id']; } } function set_categories() { $this->categories = array(); $RS = Database::ado_execute_query("SELECT a.id as catid, a.name as catname, b.id as itemcatid FROM ".Config::$db_tables['inventory_categories']." a, ".Config::$db_tables['inventory_item_categories']." b WHERE a.id=b.category_id AND b.item_id='".$this->id."'"); while($record = $RS->FetchRow()) { $this->categories[$record['itemcatid']] = array( 'id' => $record['catid'], 'name' => $record['catname'] ); } } function get_web_colors_for_size($size_id) { if(!isset($this->breakdown)) { $this->set_breakdown(); } if(!isset($this->colors)) { $this->set_colors(); } $colors = array(); // of item_color_id => color name foreach($this->colors as $item_color_id => $color_info) { if($color_info['ais_web'] == 'yes') { $colors[$item_color_id] = $color_info['name']; } } foreach($this->breakdown as $bd_id => $bd_info) { if($bd_info['size_id'] == $size_id && $bd_info['qty_instock'] > 0) { if(!Utilities::in_array_case_insensitive($this->colors[$bd_info['item_color_id']]['name'], $colors)) { $colors[$bd_info['item_color_id']] = $this->colors[$bd_info['item_color_id']]['name']; } } } asort($colors); return($colors); } function reorder_color_chart($ordering, $cc) { $newCC = array(); foreach($ordering as $color) { if(Utilities::array_key_exists_case_insensitive($color, $cc)) // must be in both arrays to appear in color chart - ie the color must be a web color (either in stock or ais) { $color = ucwords($color); $newCC[$color] = $cc[$color]; } } return($newCC); } function get_swatch_divs($Items, $Sizes) { if(!isset($this->swatchDivs)) { $this->get_color_chart($Items, $Sizes); } return($this->swatchDivs); } function get_color_chart($Items, $Sizes) { $this->swatchDivs = ''; if(!isset($this->data)) { $this->set_data(); } if(!isset($this->web_colors) || !isset($this->web_sizes)) { $this->set_web_colors_and_sizes($Sizes); } $cc = array(); // name => hex foreach($this->web_colors as $item_color_id=>$color_name) { if($this->colors[$item_color_id]['hex'] != '' || $this->colors[$item_color_id]['swatch_thumb'] != '') { $cc[$color_name] = array( 'hex' => $this->colors[$item_color_id]['hex'], 'swatch' => $this->colors[$item_color_id]['swatch'], 'swatch_thumb' => $this->colors[$item_color_id]['swatch_thumb'] ); } } if(count($cc) == 0) { // no colors for the chart $html = ''; } else { // special case(s) - eventually will want to have db fields for this // anue $anue_excludes = array(1776, 2204); // skirt, pant if($this->data['designer_id'] == 35 && !in_array($this->id, $anue_excludes)) // anue { /* row 1: white, cream, shimmercream, gold, blush, copper row 2: pink, magnolia, passion fruit, red, wine, merlot row 3: violet, pumpkin, tangerine, maize, kiwi, celadon row 4: fern, citrus, olive, sky blue, ocean, starry night, desert sky row 5: china blue, seaside, jade, navy, platinum, slate row 6: walnut, smoke, black */ // note: the following colors have been discontinued but are still in the list because we still have stock: // apple, ... // if a discontinued color does not have stock for a particular item (ie not in $cc), it will not appear in the color chart $ordering = array( 'white','ivory','cream','shimmercream','gold','blush','vicuna','copper', 'pink','magnolia','passion fruit','red','wine','merlot', 'pale grape','violet','plum','pumpkin','coral','tangerine','poppy','buttercream','maize','kiwi','celadon', 'shimmer moss','fern','citrus','apple','olive','aquamarine','ocean','sky blue','starry night', 'desert sky','china blue','seaside','jade','navy','platinum', 'slate','smoke','walnut','chocolate','black'); $cc = $this->reorder_color_chart($ordering, $cc); } // three dots $essential_styles = array( 'ST0S-001', 'ST1C-032', 'ST1V-100', 'ST1V-002', 'ST4V-003', 'ST4S-041', 'ST4W-033', 'ST2V-217', 'ST2C-035' ); if($this->data['designer_id'] == 62 && in_array($this->data['style_number'], $essential_styles)) { $ordering = array('White','Grey Heather','Light Pink','Light Blue','Navy','Gunmetal','Brown','Black'); $cc = $this->reorder_color_chart($ordering, $cc); } // bkg if($this->data['designer_id'] == 115 && $this->data['season_code'] == '007-F07') { $ordering = array('Eggplant','Linen','Black','Portobello','Chocolate','Cactus','Fuchsia','Gunmetal','French Blue','Nutmeg','BKg Red','Warm Orange','White','Loden','Cream','Spice','Butterscotch','Navy','Violet','Caramel'); $cc = $this->reorder_color_chart($ordering, $cc); } // bryn $bamboo = array( 39818=>true, 38018=>true, 34218=>false, 62418=>true, 75718=>false, 77218=>false, 73518=>true, 38218=>true, 96118=>false ); $tgab = array( 10331=>true, 32931=>false, 25031=>true, 46431=>true, 37431=>false, 30131=>true, 47931=>false, 68331=>false, 67731=>false, 62631=>true, 75531=>true, 76231=>false, 72231=>false, 73231=>true, 78231=>true ); $hvylin = array( 32941=>true, 48341=>true, 46441=>true, 31041=>false, 75541=>true, 77641=>false, 78241=>true, 47941=>true ); $textten = array( 35336=>true, 38136=>true, 47936=>true, 32436=>true, 68336=>true, 75536=>true, 73536=>false, 78236=>true ); $velv = array( 10372=>true, 42472=>true, 31072=>false, 67672=>true, 75572=>true, 78272=>true, 40372=>true, 41772=>true, 47372=>true, 95072=>true ); $thincord = array( 46403=>true, 73203=>true, 78203=>true, 44803=>true ); $wafcord = array( 48303=>true, 47903=>true, 36303=>true ); if($this->data['designer_id'] == 130 && array_key_exists($this->data['style_number'], $bamboo)) { $ordering = array('Cream','Icicle','Pear','Oat','Leaf','Autumn','Kale','Dusk','Hickory','Raisin','Black'); $cc = $this->reorder_color_chart($ordering, $cc); } elseif($this->data['designer_id'] == 130 && array_key_exists($this->data['style_number'], $tgab)) { $ordering = array('Cream','Icicle','Griffin','Oat','Leaf','Autumn','Shadow','Kale','Dusk','Portobello','Hickory','Raisin','Black'); $cc = $this->reorder_color_chart($ordering, $cc); } elseif($this->data['designer_id'] == 130 && array_key_exists($this->data['style_number'], $hvylin)) { $ordering = array('Natural','Icicle','Oat','Leaf','Kale','Dusk','Hickory','Raisin','Black'); $cc = $this->reorder_color_chart($ordering, $cc); } elseif($this->data['designer_id'] == 130 && array_key_exists($this->data['style_number'], $textten)) { $ordering = array('Cream','Icicle','Leaf','Autumn','Kale','Dusk','Hickory','Raisin','Black'); $cc = $this->reorder_color_chart($ordering, $cc); } elseif($this->data['designer_id'] == 130 && array_key_exists($this->data['style_number'], $velv)) { $ordering = array('Leaf','Dusk','Raisin','Oat','Black'); $cc = $this->reorder_color_chart($ordering, $cc); } elseif($this->data['designer_id'] == 130 && array_key_exists($this->data['style_number'], $thincord)) { $ordering = array('Icicle','Oat','Leaf','Kale','Dusk','Hickory','Raisin','Black'); $cc = $this->reorder_color_chart($ordering, $cc); } elseif($this->data['designer_id'] == 130 && array_key_exists($this->data['style_number'], $wafcord)) { $ordering = array('Icicle','Leaf','Kale','Dusk','Hickory','Raisin','Black'); $cc = $this->reorder_color_chart($ordering, $cc); } //////////////////////////////////////////////////////////// $cols = 5; $html = ''; // top and right div values based on browser if(strstr(Tracker::$browser, 'MSIE')) { $top = 195; $right = 235; //$html .= ''; } else { $top = 195; $right = 225; } $html .= ' '; $col_count = 0; foreach($cc as $color=>$info) { ++$col_count; if($col_count % $cols == 1) { $html .= ''; } $html .= ' '; if($col_count % $cols == 0) { $html .= ''; } } // clean up last row if not all cols filled if($col_count % $cols > 0) { $diff = $cols - $col_count % $cols; for($i=1;$i<$diff;++$i) { $html .= ''; } $html .= ''; } $html .= '
mouse over colors to see name
'; // popup div $divID = str_replace(' ', '', $color).'Swatch'; if($info['swatch'] != '') { // set div size based on image size -- need the .. in front of /images $swatchInfo = getimagesize('..'.$Items->color_swatch_images['normal']['web_location'].$info['swatch']); $this->swatchDivs .= ''; } elseif($info['hex'] != '') { $this->swatchDivs .= ''; } // set up thumbs if($info['swatch_thumb'] != '') { $color_thumb = ''.$color.''; $color_thumb_bg_style = ''; $color_thumb_border_width = 0; } else { $color_thumb = ''.$color.''; // for some reason (in FF anyway) the color blocks would appear bigger than the swatch thumbs $color_thumb_bg_style = 'background-color: #'.$info['hex'].';'; $color_thumb_border_width = 1; } $html .= ''; $html .= '
'.$color_thumb.'
 
'; } return($html); } function get_web_sizes_for_color($item_color_id) { if(!isset($this->breakdown)) { $this->set_breakdown(); } if(!isset($this->colors)) { $this->set_colors(); } $sizes = array(); // size_id => size of instock or ais sizes foreach($this->sizes as $size_id=>$size) { if($this->colors[$item_color_id]['ais_web'] == 'yes') { $sizes[$size_id] = $size; } else { foreach($this->breakdown as $bd_id => $bd_info) { if($bd_info['size_id'] == $size_id && $bd_info['item_color_id'] == $item_color_id && $bd_info['qty_instock'] > 0) { if(!Utilities::in_array_case_insensitive($size, $sizes)) { $sizes[$size_id] = $size; } } } } } return($sizes); } function set_web_colors_and_sizes($Sizes) { $this->web_colors = array(); $this->web_sizes = array(); if(!isset($this->breakdown)) { $this->set_breakdown(); } if(!isset($this->colors)) { $this->set_colors(); } if(!isset($this->sizes)) { $this->set_sizes($Sizes); } foreach($this->breakdown as $bd_id => $bd_info) { if($bd_info['qty_instock'] > 0 || (isset($this->colors[$bd_info['item_color_id']]['ais_web']) && $this->colors[$bd_info['item_color_id']]['ais_web'] == 'yes') ) { if($bd_info['item_color_id'] > 0 && $this->colors[$bd_info['item_color_id']]['name'] != '' && !Utilities::in_array_case_insensitive($this->colors[$bd_info['item_color_id']]['name'], $this->web_colors)) { $this->web_colors[$bd_info['item_color_id']] = $this->colors[$bd_info['item_color_id']]['name']; } if($bd_info['size_id'] > 0 && !Utilities::in_array_case_insensitive($this->sizes[$bd_info['size_id']], $this->web_sizes)) { $this->web_sizes[$bd_info['size_id']] = $this->sizes[$bd_info['size_id']]; } } } // look for ais colors foreach($this->colors as $item_color_id=>$color_info) { if($color_info['ais_web'] == 'yes') { if(!array_key_exists($item_color_id, $this->web_colors)) { $this->web_colors[$item_color_id] = $color_info['name']; } // add all sizes foreach($this->sizes as $size_id=>$size) { if(!array_key_exists($size_id, $this->web_sizes)) { $this->web_sizes[$size_id] = $size; } } } } asort($this->web_colors); // reorder web sizes because they can get ooo w/ above $web_sizes_ordered = array(); foreach($this->sizes as $size_id=>$size) { if(array_key_exists($size_id, $this->web_sizes)) { $web_sizes_ordered[$size_id] = $size; } } $this->web_sizes = $web_sizes_ordered; } function set_web_qty_max($selected_item_color_id='', $selected_size_id='') { if(!isset($this->breakdown)) { $this->set_breakdown(); } if(!isset($this->colors)) { $this->set_colors(); } // if color not input and any color is ais or if selected color is ais return web qty max default, otherwise loop thru breakdown based on color,size inputs //echo $this->data['id'].' '.$selected_item_color_id.' '.$selected_size_id.'
'; if($selected_item_color_id == '' || $selected_item_color_id == 0) { foreach($this->colors as $item_color_id=>$color_info) { if($this->colors[$item_color_id]['ais_web'] == 'yes') { $this->web_qty_max = $this->web_qty_max_default; return(TRUE); } } } else { if($this->colors[$selected_item_color_id]['ais_web'] == 'yes') { $this->web_qty_max = $this->web_qty_max_default; return(TRUE); } } $max = 0; if($selected_item_color_id == '' && $selected_size_id == '') { // loop through bd and get max foreach($this->breakdown as $bd_id=>$bd_info) { if($bd_info['qty_instock'] > $max) { $max = $bd_info['qty_instock']; } } } elseif($selected_item_color_id == '') { // loop thru bd and get max where size id matches foreach($this->breakdown as $bd_id=>$bd_info) { if($bd_info['size_id'] == $selected_size_id && $bd_info['qty_instock'] > $max) { $max = $bd_info['qty_instock']; } } } elseif($selected_size_id == '') { // loop thru bd and get max where item color id matches foreach($this->breakdown as $bd_id=>$bd_info) { if($bd_info['item_color_id'] == $selected_item_color_id && $bd_info['qty_instock'] > $max) { $max = $bd_info['qty_instock']; } } } else // both entered { $qty = $this->get_breakdown_qty_instock($selected_item_color_id, $selected_size_id); { if($qty && $qty > $max) { $max = $qty; } } } $this->web_qty_max = $max; } function get_bd_id($item_color_id, $size_id) { if(!isset($this->breakdown)) { $this->set_breakdown(); } foreach($this->breakdown as $bd_id=>$bd_info) { if($bd_info['item_color_id'] == $item_color_id && $bd_info['size_id'] == $size_id) { return($bd_id); } } return(FALSE); } function get_breakdown_qty_instock($item_color_id, $size_id, $bd_id_in='') { // inputs can be both item_color_id and size_id or just bd_id_in if(!isset($this->breakdown)) { $this->set_breakdown(); } foreach($this->breakdown as $bd_id=>$bd_info) { if($bd_id_in != '' && $bd_id == $bd_id_in) { return($bd_info['qty_instock']); } elseif($bd_info['item_color_id'] == $item_color_id && $bd_info['size_id'] == $size_id) { return($bd_info['qty_instock']); } } return(FALSE); } function set_colors() { $this->colors = array(); $RS = Database::ado_execute_query("SELECT * FROM ".Config::$db_tables['inventory_item_colors']." WHERE item_id='$this->id'", "item::set_colors"); while($row = $RS->FetchRow()) { $this->colors[$row['id']] = array( 'name' => $row['color'], 'hex' => $row['color_hex'], 'description' => $row['color_description'], 'swatch' => $row['swatch'], 'swatch_thumb' => $row['swatch_thumb'], 'ais_web' => $row['ais_web'], 'ais_store' => $row['ais_store'], 'available_date' => $row['available_date'] ); } //var_dump($this->colors); } function set_breakdown() { $this->breakdown = array(); if(!$RS = $this->get_breakdown_RS('item_color_id,size_id')) { return(TRUE); // no error reqd } while($record = $RS->FetchRow()) { $this->breakdown[$record['id']] = array( 'item_color_id' => $record['item_color_id'], 'size_id' => $record['size_id'], 'qty_instock' => $record['qty_instock'] ); } //print_r($this->breakdown);echo '


'; } function set_sizes($Sizes) { // sets this->size_scale_data and this->sizes $this->size_scale_data = array(); $this->sizes = array(); if(!isset($this->data)) { $this->set_data(); } if($this->data['size_scale_id'] == 0) { return(TRUE); // not all items have sizes - leave empty array } $this->size_scale_data = Database::ado_get_row("SELECT * FROM ".Config::$db_tables['inventory_size_scales']." WHERE id='".$this->data['size_scale_id']."'", "item::set_size_scale_data"); $this->sizes = $Sizes->get_sizes_for_scale($this->data['size_scale_id']); return(TRUE); } function order_colors() { ksort($this->colors); } function get_breakdown_RS($order='') { $sel = "SELECT * FROM ".Config::$db_tables['inventory_item_breakdown']." WHERE item_id='".$this->id."'"; if($order != '') { $sel .= " ORDER BY $order"; } return(Database::ado_execute_query($sel, 'items::get_breakdown')); } function get_images() { return($this->images); } function has_images() { return (count($this->images) > 0); } function set_web_images($Items) { $this->web_images = array(); if(!isset($this->images)) { $this->set_images($Items); } // returns false if not at least 1 complete set of images //print_r($this->images);echo '

'; foreach($this->images as $imageorder=>$image_info) { if(($image_info['medium']) && $image_info['large'] && $image_info['thumb']) { $this->web_images[] = $imageorder; } } return(count($this->web_images) > 0); } function set_images($Items) { $this->images = array(); // populates $this->images based on item_images table and whether files exist. notifies tech and designer if image files do not exist $sel = "SELECT imagefile, imageorder, caption, show_xlarge FROM ".Config::$db_tables['inventory_item_images']." WHERE item_id='$this->id' ORDER BY imageorder"; //echo $sel; $RS = Database::ado_execute_query($sel); while($record = $RS->FetchRow()) { $this->images[$record['imageorder']] = array( 'filename' => $record['imagefile'], 'caption' => $record['caption'], 'show_xlarge' => $record['show_xlarge'] ); foreach($Items->images as $image_size=>$image_info) { if(!file_exists($image_info['path'].$record['imagefile']) || $image_size == 'xlarge' && $this->images[$record['imageorder']]['show_xlarge'] == 'no') { $this->images[$record['imageorder']][$image_size] = FALSE; /* if($this->data['status_web'] == 'active') { $body = "item id: ".$this->data['id']."\n"; $body .= "file: ".$image_info['path'].$record['imagefile']."\n"; $body . "www.".Config::$domain."/admin/items/?item_id=$this->data['id']"; Utilities::notify(Config::$tech_email, "hb ERROR: missing image file", $body, Config::$site_manager_email); } */ } else { $this->images[$record['imageorder']][$image_size] = TRUE; } } } //print_r($this->images);echo '

'; } // end set_images function is_on_sale($which) { $which = ($which == 'store') ? '' : '_web'; // to match w/ db fields return($this->data['sale_price'.$which] > 0 && $this->data['sale_price'.$which] < $this->data['price'.$which]); } function set_on_sale($which) { $this->{"on_sale_$which"} = $this->is_on_sale($which); } function set_on_promotion_web($Promotion) { if($Promotion->get_id()) { switch($Promotion->get_id()) { case 1: // at this point just have to know that it applies to all $this->on_promotion_web = TRUE; return(TRUE); break; case 2: // at this point just have to know that it applies to all $this->on_promotion_web = TRUE; return(TRUE); default: $this->on_promotion_web = FALSE; return(FALSE); } } else { $this->on_promotion_web = FALSE; return(FALSE); } } function web_quantity_select($preselected, $name='qty', $onchange='', $css='') { $qty_select = ''; return($qty_select); } function get_promotion_price($Promotion) { // either a % or $ amount off if($Promotion->get_discount_dol() > 0) { return ($this->get_on_sale('web')) ? $this->data['sale_price_web'] - $Promotion->get_discount_dol() : $this->data['price_web'] - $Promotion->get_discount_dol(); } return ($this->get_on_sale('web')) ? $this->data['sale_price_web'] * ( (100 - $Promotion->get_discount_pct()) / 100 ) : $this->data['price_web'] * ( (100 - $Promotion->get_discount_pct()) / 100 ); } function get_web_price($Promotion) { if(!isset($this->data)) { $this->set_data(); } if($this->get_on_promotion_web($Promotion)) { return($this->get_promotion_price($Promotion)); } return ($this->get_on_sale('web')) ? $this->data['sale_price_web'] : $this->data['price_web']; } function get_store_price() { if(!isset($this->data)) { $this->set_data(); } if(!isset($this->on_sale_store)) { $this->set_on_sale('store'); } return ($this->on_sale_store) ? $this->data['sale_price'] : $this->data['price']; } function img_src($Items, $image_size, $image_order) { return($Items->images[$image_size]['web_location'].$this->images[$image_order]['filename']); } function img_html($Items, $image_size, $image_order=1, $img_name='', $img_alt='') { if(!isset($this->images)) { $this->set_images($Items); } if(count($this->images) == 0) { $html = ' '; } else { $img_src = $this->img_src($Items, $image_size, $image_order); $img_alt = ($img_alt != '') ? $img_alt : $this->images[$image_order]['caption']; // defaults to caption if($img_alt == '') { $img_alt = 'try it!'; } $html = ''; if($image_size == 'large' && $this->images[$image_order]['xlarge']) { $href = '/popups/xlargepic.hello?item_id='.$this->id.'&image='.$image_order; if(isset($_GET['force'])) // preview from admin { $href .= '&force'; } $html .= ''; } $html .= 'img_tag_attr[$image_size].' alt="'.$img_alt.'" border="0" />'; if($image_size == 'large' && $this->images[$image_order]['xlarge']) { $html .= ''; } } return($html); } function taxable_under50($Categories) { // if item belongs to a category that is taxable_under50 then the item is taxable foreach($this->categories as $itemcatid=>$cat_info) { $CategoryRecord = Database::get_record_for_object($Categories, $cat_info['id']); if($CategoryRecord['taxable_under50'] == 'yes') { return(TRUE); } } return(FALSE); } function get_tax_amount($Categories, $Promotion, $type='web') { // this assumes it is an in store purchase or a web purchase shipping to ct --> those tests must be done prior to this call $price = ($type = 'web') ? $this->get_web_price($Promotion) : $this->get_store_price; return ($price >= 50 || $this->taxable_under50($Categories)) ? .06 * $price : 0; } function get_primary_category() { return(Database::ado_get_one("SELECT a.name FROM ".Config::$db_tables['inventory_categories']." a, ".Config::$db_tables['inventory_item_categories']." b WHERE a.id=b.category_id AND b.item_id=".$this->id." ORDER BY b.id", "Item:: primary_category")); } function backorder_date($item_color_id) { // returns future date if inventory_item_colors.available_date is more than 2 weeks in the future if(Utilities::date_compare($this->colors[$item_color_id]['available_date'], date("Y-m-d")) > Utilities::convert_time_to_sec(0,0,14)) { return(Utilities::informal_date($this->colors[$item_color_id]['available_date'])); } return(FALSE); } function is_preorder($item_color_id=0, $size_id=0) { // true if not in stock and item.available_date is more than 2 weeks away return ($this->get_breakdown_qty_instock($item_color_id, $size_id) <= 0 && $this->data['available_date'] != '0000-00-00' && Utilities::date_compare($this->data['available_date'], Utilities::date_convert_to_mysql(date("m/d/y"))) > Utilities::convert_time_to_sec($min=0,$hr=0,$day=14)) ? TRUE : FALSE; } } ?>