These gifts
might be deliverable by the next day if ordered by mid-afternoon.
See individual retailer\'s website for specifics and limitations. Delivery deadlines vary by time zone & retailer, and may exclude weekends & holidays.
LM
} #endsub format_qa_summary_last_minute
sub _get_company_name {
my ($data_ref,$store_ref) = @_;
my $company = $$store_ref{'d'}{$$data_ref{'store_id'}}{'company'};
# Get the company name from the list of gifts. The variable we were getting it from before isn't always populated.
my @gift_nums = keys(%{$$data_ref{'gifts'}});
$company ||= $$data_ref{'gifts'}{$gift_nums[0]}{'company'};
# Okay, we've tried everything that's already populated. Get the name from the database as a last resort.
$company ||= &company_name_from_db($$data_ref{'store_id'});
$company =~ s/\&/&/g;
$company =~ s/\"/"/g;
return $company;
}
sub _get_parent_cats {
my ($data_ref) = @_;
#### Define variables and hash keys to be used later ####
my @sel_ids = split /,/, $$data_ref{'new_cats'}{'base_cats'};
#### Build already selected list ####
my @parent_arr;
my @cat_ids;
for (my $i = 0; $i < scalar(@sel_ids); $i++) {
my %parent_hash;
my $cat_id = $sel_ids[$i];
push(@cat_ids,$cat_id);
$parent_hash{url} = lc(get_cat_link(\@cat_ids,$data_ref)) ;
$parent_hash{cat_id} = $cat_id;
$parent_hash{category} = $$data_ref{'cm'}{'d'}{$cat_id}{'category'};
#$parent_hash{url} = "javascript:parent.location='$$data_ref{'cm'}{'d'}{$cat_id}{'undo_link'}'";
push @parent_arr, \%parent_hash if ($parent_hash{cat_id} && $parent_hash{category} && $parent_hash{url});
}
return \@parent_arr;
}
sub get_cat_link {
my ($cat_ids,$data_ref) = @_;
my $vector_str = $data{'orig_vector'};
my @vector_arr = split(':',$vector_str);
my @filter_cats;
if($$data_ref{'new_cats'}{'filter_cats'} ne ''){
my @filter_cats = split(/,/,$$data_ref{'new_cats'}{'filter_cats'});
push(@$cat_ids,@filter_cats);
}
sort @$cat_ids;
$vector_arr[5] = join(',',@$cat_ids);
my $new_vec = join(':',@vector_arr);
my $sql = "SELECT Path FROM Directory_Schema_7x0 WHERE Vector = '$new_vec' AND Status = '1'";
my $sth = &sql_query($d{'hndl'}{'schdb'}, $sql);
if ($sth->NumRows == 1) { # We have an SE friendly link
my %hash = $sth->FetchHash;
return '/'.$$data_ref{'base_script'}. lc($hash{'Path'});
}
else{
my $new_enc_vec = FG::Search::convert_vector_url($new_vec);
$new_enc_vec = FG::Search::encode_vector($new_enc_vec);
return '/'.$$data_ref{'base_script'}.$$data_ref{'directory'}.$new_enc_vec.'/';
}
}
sub _get_options_parent_cats {
my ($data_ref) = @_;
#### Define variables and hash keys to be used later ####
my @sel_ids = split /,/, $$data_ref{'new_cats'}{'filter_cats'};
#### Build already selected list ####
my @parent_arr;
if (scalar(@sel_ids) > 0 && $$data_ref{'menu'}{'disable_dynamic'} != 1) {
my @test = split(':' , $$data_ref{'vector'});
my @cat_ids = split(',',$$data_ref{'new_category_ids'});
for (my $i = 0; $i < scalar(@sel_ids); $i++) {
my $add_vector = "";
my %parent_hash;
my $cat_id = $sel_ids[$i];
if(scalar(@sel_ids) eq 1){
$parent_hash{url} = '/'.$data{'base_script'}.'/';
}
else{
$parent_hash{url} = "";
foreach(@cat_ids){
if($_ ne $cat_id){ $add_vector .= $_ .","; }
}
}
$test[5] = $add_vector;
my $decoded_vector = join(':',@test);
my $new_enc_vector = FG::Search::convert_vector_url($decoded_vector);
$new_enc_vector = FG::Search::encode_vector($new_enc_vector);
$parent_hash{vector} = $new_enc_vector;
$parent_hash{cat_id} = $cat_id;
$parent_hash{category} = $$data_ref{'cm'}{'d'}{$cat_id}{'category'};
push @parent_arr, \%parent_hash if ($parent_hash{cat_id} && $parent_hash{category});
}
} #endif
if(scalar(@parent_arr) > 0 ){ $$data_ref{'new_settings'}{'filters_base_cat'} = $parent_arr[-1]{'cat_id'}; }
else { $$data_ref{'new_settings'}{'filters_base_cat'} = "" }
return \@parent_arr;
}
sub _get_left_children_list{
my ($data_ref,$max_cat) = @_;
my @menu_ids = split /,/, $$data_ref{'cm'}{'i'}{'available'}{'1'};
unless( scalar(@menu_ids) ){
return;
}
my @cat_arr;
my @parents = split(',' , $data{'new_cats'}{'base_cats'});
my $base_id = $parents[$#parents];
for (my $i = 0; $i < $max_cat; $i++){
my %cat_hash;
my $cat_id = $menu_ids[$i];
if(!($base_id) || $$data_ref{'cm'}{'d'}{$cat_id}{'parent_id'} eq $base_id || $$data_ref{'cm'}{'d'}{$cat_id}{'parent_id'} eq $$data_ref{'directory_id'} ){
$cat_hash{category} = $$data_ref{'cm'}{'d'}{$cat_id}{'category'};
$cat_hash{url} = lc($$data_ref{'cm'}{'d'}{$cat_id}{'link'});
$cat_hash{title} = $$data_ref{'cm'}{'d'}{$cat_id}{'add_reltag'};
push (@cat_arr, \%cat_hash);
}
}
return \@cat_arr;
}
sub _get_left_options_list{
my ($data_ref,$max_cat) = @_;
my @menu_ids = split /,/, $$data_ref{'cm'}{'i'}{'available'}{'1'};
unless( scalar(@menu_ids) ){
return;
}
my @cat_arr;
my $base_id = 0;
my @parents = split(',' , $data{'new_cats'}{'base_cats'});
if(scalar(@parents) > 0){ $base_id = $parents[$#parents]; }
for (my $i = 0; $i < $max_cat; $i++){
my %cat_hash;
my $cat_id = $menu_ids[$i];
if($base_id ne 0 && $$data_ref{'cm'}{'d'}{$cat_id}{'parent_id'} ne $base_id && $$data_ref{'cm'}{'d'}{$cat_id}{'parent_id'} ne $$data_ref{'directory_id'} ){
$cat_hash{category} = $$data_ref{'cm'}{'d'}{$cat_id}{'category'};
$cat_hash{url} = lc($$data_ref{'cm'}{'d'}{$cat_id}{'link'});
$cat_hash{title} = $$data_ref{'cm'}{'d'}{$cat_id}{'add_reltag'};
$cat_hash{vector} = substr $$data_ref{'cm'}{'d'}{$cat_id}{'add_enc_vector'},0,-1;
push (@cat_arr, \%cat_hash);
}
}
return \@cat_arr;
}
sub _get_any_cat_link {
my ($data_ref, $qa_sum_ref) = @_;
# if any sub category is selected along with filters.
return $$data_ref{'cm'}{'d'}{'any_cat_link'} if( $$data_ref{'cm'}{'d'}{'any_cat_link'} );
#no sub category is selected but check if any flter is selected.
my @config_keys = (8, 6, 7, 3, 5, 99);
foreach my $filter (@config_keys){
if( $$qa_sum_ref{$filter}{'category_id'} > 0 ){
return $ENV{'REQUEST_URI'};
}
}
# no sub category is selected and no filters are selected. For example /categories/animals.
return '/services/gift-ideas/';
# No filters are selected, therefore any_category link should go to /Services/Gift-Ideas.
#my $uri = $ENV{'REQUEST_URI'};
#$uri =~ m!(^/categories/.+?/).*!;
#return '/services/gift-ideas/' if $1;
# return $ENV{'REQUEST_URI'};
# ($$data_ref{'cm'}{'d'}{'any_cat_link'}) ? return $$data_ref{'cm'}{'d'}{'any_cat_link'} : return $ENV{'REQUEST_URI'};
}
sub format_gift_boxes{
my ($data_ref,$pref_ref) = @_;
$$data_ref{'url_encoded_vector'} = FG::Utils::url_encode($$data_ref{'vector'});
for (my $i = 0; $i < $$data_ref{'num_shown'}; $i++) {
$$data_ref{'gifts'}{$i}{'name'} =~ s/\"/"/g;
$$data_ref{'gifts'}{$i}{'name'} = ( length($$data_ref{'gifts'}{$i}{'name'}) > 102 ? substr($$data_ref{'gifts'}{$i}{'name'},0,102) : $$data_ref{'gifts'}{$i}{'name'} );
if ($$data_ref{'gifts'}{$i}{'image_m'} ne '') {
$$data_ref{'gifts'}{$i}{'image_cdn_src'} = FG::Utils::add_cdn_img_path($$data_ref{'gifts'}{$i}{'image_m'});
}
elsif ($$data_ref{'gifts'}{$i}{'image_s'} ne '') {
my $src = $$data_ref{'gifts'}{$i}{'image_s'};
$$data_ref{'gifts'}{$i}{'image_s_cdn_src'} = FG::Utils::add_cdn_img_path($$data_ref{'gifts'}{$i}{'image_s'});
}
}
return 1;
}
sub format_msps{
my ($msp_ref, $vwo_test_content_text) = @_;
my @msp_ids = split(/\,/, $msp_ref->{'i'}{'sort_rank'});
my $editor_image= $s{'net'}{'webs'};
my $live_image = $s{'com'}{'images'};
my $msps;
unless( @msp_ids ){
return 1;
}
my @my_msps;
foreach my $msp_id( @msp_ids ){
my %new_msps;
$new_msps{'headline'} = $$msp_ref{'d'}{$msp_id}{'headline'};
$new_msps{'enc_headline'} = _html_encode_entities($new_msps{'headline'});
$new_msps{'description'} = $$msp_ref{'d'}{$msp_id}{'description'};
$new_msps{'display_url'} = $$msp_ref{'d'}{$msp_id}{'display_url'};
$new_msps{'url'} = $$msp_ref{'d'}{$msp_id}{'cpc_url'};
$new_msps{'image'} = $$msp_ref{'d'}{$msp_id}{'image'};
$new_msps{'headline'} =~ s/'/\\'/g;
$new_msps{'headline'} =~ s/"/"/g;
next unless( $new_msps{'headline'} && $new_msps{'description'} && $new_msps{'display_url'} );
if( $new_msps{'image'} && $new_msps{'image'} =~ /\_PEND/ ){
# Image is a pending image so fetch from local machine!
$new_msps{'image'} = "$editor_image/Graphics/MSP/" . $new_msps{'image'};
}
elsif( $new_msps{'image'} ){
$new_msps{'image'} = "$live_image/Graphics/MSP/".$new_msps{'image'};
}
else{
$new_msps{'image'}= "$live_image/Graphics/fg/Registry/no_product.gif";
}
$new_msps{'image'} = FG::Utils::add_cdn_img_path($new_msps{'image'});
push( @my_msps , \%new_msps );
}
return \@my_msps;
}
sub format_qa_summary {
my ($data_ref, $qa_sum_ref, $html_key) = @_;
my $mask = $$qa_sum_ref{'mask'};
$mask = 0 if ($$data_ref{'most_popular'} == 1); # Don't mask any inputs for most popular search
my $binary_mask = FG::Utils::dec2bin($mask, 6);
my @config_keys = (8, 6, 7, 3, 5, 99);
my %config = (
8 => { html_key => 'menu_genid',
label => 'RECIPIENT',
id => 'recipient',
default => 'All',
},
6 => { html_key => 'menu_whoid',
label => 'RELATIONSHIP',
id => 'relationship',
default => 'Any',
},
7 => { html_key => 'menu_ageid',
label => 'AGE',
id => 'age',
default => 'All',
},
3 => { html_key => 'menu_occid',
label => 'OCCASION',
id => 'occasion',
default => 'Any',
},
5 => { html_key => 'menu_typids',
label => 'GIFT TYPE',
id => 'gift_type',
default => 'Any',
},
99 => { html_key => 'menu_prcids',
label => 'PRICE RANGE',
id => 'price_range',
default => 'Any',
},
);
#### Make summary ####
$html{'qa_summary'} = <
HEAD
my $prior_summary = 0;
for (my $i = 0; $i < scalar(@config_keys); $i++) {
my $class = $config_keys[$i];
my $category = $$qa_sum_ref{$class}{'category'};
$category =~ s/^a //; # Turn "a Girl" into "Girl" for summary menu display purposes
my $html_key = $config{$class}->{'html_key'};
next if (substr($binary_mask,$i,1) eq '1' && $$qa_sum_ref{$class}{'category_id'} eq '');
if ($html{$html_key} ne '') { # Put in overlay menu if present
$html{'qa_summary'} .= <