#!/usr/bin/perl require 'td_global.pl'; ################################################################### # # # Program Name : am2_issues.cgi # # Author : James Xing # # Description : List all closing market highlights available. # # # ################################################################### use CGI; use DBI; use lib '..'; use paths; require 'server_root.pl'; use lib &paths::get('packages'); use do_template; use CGI::Carp qw(fatalsToBrowser); $doc_root = "/webAS/web/docs"; require 'includes.pl'; require './packages/am_db.pl'; #hide the bad free messages from displaying $SIG{__WARN__} = sub { warn $_[0] unless $_[0] =~ /^Bad free/ }; my $cgi = new CGI; my $lang = $cgi->param('lang'); my (@fund_date, @title, @highlight, @cash_income); my (@equities, @globals, @prod_id); $lang = 'EN' if (! $lang); my $web_cgi = &paths::get('web_cgi'); &get_index_values; $template = &get_html_template($lang); &generate_page($template, $lang); exit; ################## # Subroutines # ################## sub get_index_values { &login; $sh = $dbh->prepare("select substr(monthname(fund_date),1,3) || ' ' || ltrim(rtrim(char(day(fund_date)))) || ', ' || ltrim(char(year(fund_date))), title, prod_id from market_highlight where CURRENT DATE between actvtn_dt and xprtn_dt and approval_ind = 1 and lang_cd = '$lang' order by fund_date desc") || die "$DBI::errstr\n"; $sh->execute; my ($t1, $t2, $t3); while (($t1, $t2, $t3) = $sh->fetchrow) { push @fund_date, $t1; push @title, $t2; push @prod_id , $t3; } $sh->finish; &logout; } sub get_html_template { my ($lang) = @_; my $template = ($lang eq "FR") ? "./templates/french/am2_index.html" : "./templates/english/am2_index.html"; return $template } sub generate_page { my ($template, $lang) = @_; my $html = ''; my (%ins, $page); for $i (0 .. $#prod_id) { my $link = "$web_cgi/am/am2_details.cgi?lang=$lang&prod_id=$prod_id[$i]"; $html .= ""; $html .= "$fund_date[$i]"; $html .= ""; $html .= "$title[$i] "; } $ins{fund_list} = $html; $url_root = &paths::get('url_root').'/'; $am_root = &paths::get('am_root'); $am_mutual_root = &paths::get('am_mutual_root'); $am_dev_root = &paths::get('am_dev_root'); $am_dev_cgi = &paths::get('am_dev_cgi'); $am_https_cgi = &paths::get('am_https_cgi'); open FILE, "$template" || die 'COULD NOT OPEN TEMPLATE. TRY AGAIN. IF PROBLEM PERSISTS REPORT IT TO SYSTEM ADMINISTRATOR.'; while ($line = ) { $line =~ s//$ins{fund_list}/g; $line =~ s//$url_root/g; $line =~ s//$am_root/g; $line =~ s//$am_mutual_root/g; $line =~ s//$am_dev_root/g; $line =~ s//$am_dev_cgi/g; $line =~ s//$am_https_cgi/g; $line =~s//$HeadStuff/g; $line =~s//$GlobalNav/g; $line =~s//$Footer/g; $line =~s//$GreenNav/g; $line =~s//$LeftNav/g; $page .= $line if ($line); } close FILE; print $cgi->header; print $page; } ############################END OF am2_issues.cgi######################### 1;