package NVC; use strict; #$Id: NVC.pm,v 1.28 2001/02/02 23:43:08 umar Exp $ ##################################################### # All opinions about CgiBase belong to Max Khrapov # ##################################################### use lib '/web/auto/lib'; use lib '/web/auto/lib/NVC'; use vars qw(@ISA @EXPORT_OK); use CGI; use Exporter; @ISA = qw(Exporter); @EXPORT_OK = qw(get_apurl if_has_lm html_header html_footer hidden_fields quote_form is_popup cgi_param cgibase all_params nvc_debug); ### let's save all the CGI parameters in memory ### otherwise CgiBase will destroy everything my $cgi = new CGI; my @param = $cgi->param; my %cgi; my $i; foreach $i (@param) { my @ar = $cgi->param($i); if(@ar == 1) { my $j = shift @ar; $cgi{$i} = $j; } else { my $k = 1; my $j; foreach $j (@ar) { $cgi{"$i$k"} = $j; ++$k; } } } ### Try not to use CgiBase unless your manager sais you absolutely must my $product_code = '09.002.00'; ### The real thing my $cgibase; my $web_id; my $invsearchurl; my $popup; my $disable_inv; my $ap_url; my $cb_html_header; my $cb_html_footer; eval ' use CgiBase; $cgibase = new CgiBase $product_code; $web_id = $cgibase->{web_id}; $popup = $cgibase->{CGIParams}->{popup}; $invsearchurl = $cgibase->{CGIParams}->{invsearchurl}; $disable_inv = $cgibase->{CGIParams}->{disable_inv}; $ap_url = $cgibase->{CGIParams}->{autoposturl}; $cb_html_header = $cgibase->get_header; $cb_html_footer = $cgibase->get_footer; '; ### Defaults $web_id = 79532 unless $web_id; ### Sometimes the filename of the actual program ### is different. I think the best way to deal with ### it is not to second guess what it could be, but ### have production people make a soft link to the ### right program $invsearchurl = "new_inventory-results.cgi" unless $invsearchurl; $popup = 0 unless $popup; my $hidden_fields = ""; foreach $i (keys %cgi) { $hidden_fields .= qq(\n); } ######################################################## # # Subroutines # ######################################################## ######################################################### sub get_apurl ######################################################## { return $ap_url; } ######################################################## sub if_has_lm ######################################################### { my $tf = 0; my ($status, $purchased, $purchases); my $lm_product_code = '600'; eval "use lib '/web/lib'; use Purchases::Purchases_Read; "; eval "\$purchases = new Purchases_Read"; $status = $purchases->check_purchase (\$purchased, $cgibase->{WebSite}->{web_num}, $lm_product_code); if ($purchased){ $tf = 1; } #print "Content-type: text/html\n\n"; #print "\n"; #print "\n"; #print "TF is: $tf
"; #print ""; #exit(0); return $tf; } ####################################################### # usage: nvc_debug($variable_name) # $variable_name means the vaiable you want to print out ############################################################ sub nvc_debug { my ($myparam) = @_; print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "$myparam
"; print ""; exit(0); } ######################################################## sub all_params { return keys %cgi; } ################################################################# sub cgi_param { my $param = shift; return $cgi{$param}; } ############################################################ sub cgibase { return $cgibase; } ############################################################ sub is_popup { if($popup) { return 1; } else { return 0; } } ############################################################ sub html_header { if ($cb_html_header =~ /Unable\s+to\s+open\s+file/) { $cb_html_header =< Make \& Match Results(Default HTML header and footer) ENDD } return $cb_html_header; } ########################################################## sub html_footer { if ($cb_html_footer =~ /Unable\s+to\s+open\s+file/) { $cb_html_footer =< ENDD } return $cb_html_footer; } ########################################################## sub hidden_fields { return $hidden_fields; } ########################################################## sub quote_form { my $is_frame = shift; my $email_url; if ($is_frame) { $email_url = "f_nvc_mailtolm.cgi"; }else { $email_url = "nvc_mailtolm.cgi"; } my $mymake = $cgi{"DivisionName"}; my $model = $cgi{"ModelName"}; # Get rid of the space and substitue space with "+" if there is any space between word $model =~ s/^\s+//; $model =~ s/\s+$//; $model =~ s/\s+/+/g; #add "+" to any multi-word makes my $year = $cgi{"ModelYear"}; my $hidden_fields = hidden_fields(); ###config whether quote_page should display inventery searching my $quote_begin_sentence; if ($disable_inv){ $quote_begin_sentence =<<"EOF";

You can now send a request for a quote on the vehicle you configured directly to our dealership. We ask that you provide your contact information, which will allow us to follow up with you in a timely manner.

EOF }else { $quote_begin_sentence =<<"EOF";

You can now search the new vehicle inventory to find the closest match to the vehicle you configured.

You can also send a request for a quote on the vehicle you configured directly to our dealership. We ask that you provide your contact information, which will allow us to follow up with you in a timely manner.

EOF } my $html = <<"EOF";

Congratulations! Your vehicle is configured!

$quote_begin_sentence
$hidden_fields

Email Form

Message
The information about your preferences will be included with this message. If you would like to send some additional comments, you can enter them in the box below.
Comments:
Contact Information
*First Name:
*Last Name:
*Email:
*Home Phone:
*Day Phone:
Fax:
Preferred Contact:
*Address:
*City:
*State:
*Zip:
*These fields are required
EOF return $html; } ############################################################# 1;