#!/usr/bin/perl # CollapsedSubs: Main_HTML_Doc my_read_CGI_input ConnectToDB DisConnectFromDB render_price_list_html Read_Inventory_DB urlencode ################################################################################ ################################################################################ ##### This code tells the browser what MIME type the content is. ##### ##### All content delivered by this script is HTML ##### ##### ##### ################################################################################ ################################################################################ #use CGI::Carp qw(fatalsToBrowser); #comment out the above line when you're done debugging this script # start user configuration ################################################################################ print "Content-type: text/html \n\n\r\n\r\n\r" unless ($content_type_printed); $content_type_printed++; ################################################################################ # the mysql database table name that this script will use for the products table. $Feature_Name = "Cue Repair Price List"; $Feature_Link_Name = "price list"; $Inv_Table="services"; $Cart_Table = "repair_carts"; #$Sales_Order_Table = "service_orders"; #$Dealer_Table ="dealer_db"; $item_number_field = "Service_ID"; $item_name_field = "Service_Name"; $item_amount_field = "Reg_Price"; $item_sale_price_amount_field = "Sale_Price"; $item_active_field = "Active"; #$item_View_Permits_field ="View_Permits"; #$default_View_Permits ="%R%"; $item_category_field = "Category"; $cart_long_name ="Repair Ticket"; $cart_short_name ="Ticket"; $cart_url = "/cgi-bin/cue-shop.pl"; # Enter the currency symbols PayPal uses to designate US dollars # or Euros or Pounds Sterlings. Enter a backslash before the $ symbol. # US: $ # Euros: � # Pounds Sterling: � # Canadian Dollar (C$) # Japanese Yen (�) $m_symbol = "\$"; # The currency of the payment is U.S.Dollars: USD # The currency of the payment is British Pounds Sterling: GBP # The currency of the payment is Euros: EUR # The currency of the payment is Canadian Dollar: CAD # The currency of the payment is Yen: JPY $currency_code = "CAD"; ################################################################################ ################################################################################ # end user configuration ---> Begin Main Exec $selfURL = $ENV{SCRIPT_NAME}; #$selfURL = "/cgi-bin/price-list.pl"; $|++; #dont't buffer output # find out the OS if ($^O eq 'MSWin32' || $ENV{'OS'} eq 'Windows_NT') { # this one for windows $windows = 'Yes'; $slash = '\\'; } else { $windows = 'No'; $slash = '/'; } #load required perl modules or libraries #my $dbh; my $db_params = "admin/params.pl"; my $db_common = "wsdbi_params.pm"; eval { #use strict; use DBI; require $db_common; require $db_params; require 'cookie.pl'; }; #check for load errors if ($@) { &my_load_error_doc($@); exit(0); } # connect to DB, read CGI data, verify Login, SITe_ConnectToDB(); my_read_CGI_input(); ##### define time variables my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $mon = $mon + 1; $year = $year + 1900; $accessTime = "$hour:$min:$sec"; $AN = int(rand(10000)); Main_HTML_Doc(); DisConnectFromDB(); #End of main perl code ################################################################################ ####### this sub returns the script specific load error doc ################################################################################ sub Main_HTML_Doc(){ #Determine Page Content $main_content = render_price_list_html() if ($data{cmd} eq ""); #Default Content $main_content = Read_Inventory_DB() if ($data{cmd} eq "List"); $main_content = Read_Inventory_DB() if ($data{cmd} eq "ShowItem"); print "Content-type: text/html \n\n\r\n\r\n\r" unless ($content_type_printed); $content_type_printed++; print qq~
$my_ws_logo_code Bunjee Canada.com
$Feature_Name |
|
$my_main_links | |
$Feature_Name (Currency: $currency_code)
|
|
@error_messages $main_content | |
© Copyright 2003 $my_Business_name
All Rights Reserved. Trademarks and images not proprietary to
$my_Business_name are used under license or with permission from their
respective owners.
Spark-IT Driven |
Can't connect to server.
Reason: $DBI::errstr"; exit; } } sub DisConnectFromDB(){ if (defined $sth){ $sth->finish();} if(defined $dbh){ $dbh->disconnect or die "Can't disconnect from database. Reason: $DBI::errstr" and undef $dbh; } } sub render_price_list_html(){ my $html = qq~
~;
my $dbquery = qq~SELECT * FROM $Inv_Table WHERE $item_active_field LIKE 'TRUE'
AND Category LIKE '$category' ORDER BY $item_name_field
~;
my $sth = $dbh -> prepare($dbquery) or print "Query syntax error. $dbquery. Reason: $DBI::errstr.";
if( not $sth -> execute())
{
print " Can't execute query: Reason: $DBI::errstr.";
$sth -> finish;
DisConnectFromDB();
exit;
}
$i=1;
while(my $sku_ref=$sth->fetchrow_hashref())
{
if ($sku_ref->{$item_sale_price_amount_field} < $sku_ref->{$item_amount_field})
{
$temp_price = "$sku_ref->{$item_sale_price_amount_field}";
}
else
{
$temp_price = "$sku_ref->{$item_amount_field}";
}
my $temp_Item = $sku_ref->{$item_number_field};
$html .= qq~$i) $sku_ref->{$item_name_field}
~; $i++; } $html .=qq~ | ~;
if ($col == 3)
{
$col = 0;
$html .=qq~
Can't execute query:
$dbquery.
Reason: $DBI::errstr."; $sth -> finish; DisConnectFromDB(); exit; } my $html = qq~
$data{Brand} $content_name
|
||
$item_number MSRP: $m_symbol$sku_ref->{MSRP} $item_sale_price $add_form_HTML |
$item_name $product_img_URL $sku_ref->{Caption} $sku_ref->{Details} |
|
$sku_ref->{Expanded_Details} | ||
Repair Item |
Repair Description |
|
$item_number MSRP: $m_symbol$sku_ref->{MSRP} $item_sale_price $detail_link $add_form_HTML |
$item_name $product_img_URL $sku_ref->{Caption}$sku_ref->{Details} |