scratchpad
vagnerr
<hr />
<CODE>
# -----------------------------------------------------------------------------
# Subroutine: produceDailyReport
# Parameters: hashref argument hash produced by getopts
# hashref merchant's contact data
# hashref transactional data
# Returns: Nothing
# =============================================================================
# runs through the list of transactions collating a report for sending to the
# merchant.
# If there is any success/fail data from customer reports or CGI calls then
# this is also included.
# -----------------------------------------------------------------------------
sub produceDailyReport{
my $opts = shift();
my $merchantInfo = shift();
my $data = shift();
my $email_address = $opts{'e'} ||
$merchantInfo->{'CONTACT'}->{'SBDAYMAIL'} ||
$merchantInfo->{'CONTACT'}->{'SBDAYMAILO'};
my $template = HTML::Template->new(
filename => SBR_MERCHANTTEMPLATEDAILY,
die_on_bad_params => 0,
loop_context_vars => 1,
global_vars => 1);
$template->param('transactions',$data);
$template->param('report_type',"Daily");
$template->param('MNAM',$merchantInfo->{'NAME'});
$template->param('merchant_name',$merchantInfo->{'NAME'});
$template->param('current_date',scalar(localtime()));
$template->param('period_start',join '/',reverse split '-',calcYesterday($opts));
$template->param('period_end',join '/',reverse split '-',calcYesterday($opts));
#create the totals for passsed/failed transactions
my $totals = totalData($data);
$template->param('total_passed',$totals->{'total_passed'});
$template->param('total_failed',$totals->{'total_failed'});
$template->param('no_passed',$totals->{'no_passed'});
$template->param('no_failed',$totals->{'no_failed'});
$template->param('total_trans',$totals->{'total_trans'});
$template->param('no_trans',$totals->{'no_trans'});
$template->param('CURS',$data->[0]->{'CURS'}); #we need the currency :)
$template->param('currency_symbol',$data->[0]->{'CURS'});
#make sure template is aware of email and cgi reports
if(isCustomerReport($opts)){
$template->param('customer_reports',1);
}
if(isMerchantCGICalls($opts)){
$template->param('cgi_calls',1);
}
my $msg = MIME::Lite->new(
From => SBR_MERCHANTFROMADDRESSDAILY,
To => $email_address,
Subject => SBR_MERCHANTSUBJECTDAILY,
Type => 'text/html',
Data => $template->output()
);
#we need to add any images to the mail if they exist
my $parser = HTML::LinkExtor->new();
$parser->parse($template->output());
foreach my $link ($parser->links){
if ($link->[0] eq 'img'){
my_print("Image found [".$link->[2]."] ");
if ($link->[2] =~ /^https?:\/\//){
my_print("Absolute! Ignored.\n");
}else{
my ($imgtype,$junk) = reverse split '\.',$link->[2];
$imgtype =~ s/^jpg$/jpeg/; #propper mime name?
if(open(TEST,"<".$link->[2])){
my_print("Attaching\n");
close(TEST);
$msg->attach(Type =>'image/'.$imgtype,
Path =>$link->[2],
Filename=>$link->[2],
#Disposition => 'inline');
Disposition => 'attachment');
}else{
my_print("Not found, Skipped!!\n");
}
}
}
}
if($opts{'d'}){
#debug mode
my_print($msg->as_string);
}else{
$msg->send();
}
return 1; #stub
}
</CODE>
<STRONG>-------CUT--------------</STRONG>
<CODE>
<html>
<head>
<title>Test form</title>
<script type="text/JavaScript">
<!--
function storeCaret (textEl){
if (textEl.createTextRange){
textEl.caretPos = document.selection.createRange().duplicate();
}
}
function insertAtCaret (textEl, text){
if (textEl.createTextRange && textEl.caretPos) {
var caretPos = textEl.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?
text + ' ' : text;
}else{
textEl.value += text;
}
}
function addItem(label){
//document.display.showStuff.value += "%"+label+"%";
insertAtCaret(document.display.showStuff,label);
}
-->
</script>
</head>
<body>
<h1>Test Form</h1>
<form name="display" method="post" action="">
<input type="button" value="test1" onclick="javascript:addItem('TEST')">
<input type="button" value="test2" onclick="javascript:addItem('ABCD')">
<input type="button" value="test3" onclick="javascript:addItem('RGFD')">
<input type="button" value="test4" onclick="javascript:addItem('HGFD')">
<br>
<textarea name="showStuff" rows="5" cols="80" wrap="off" onselect="storeCaret(this);" ond
blclick="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this)"></textarea>
</form>
</body>
</html>
</CODE><BR><A HREF="http://perlmonks.org/index.pl?node_id=132236">Juerd</A><BR><A HREF="http://perlmonks.org/index.pl?node_id=152489">Getting Started with GnuPG and GPG</A><BR><A HREF="http://perlmonks.org/index.pl?node_id=153046">Professional Employees and Works for Hire</A><BR><A HREF="http://perlmonks.org/index.pl?node_id=152924">Alternate Monk Stats Listing</A><BR><A HREF="http://perlmonks.org/index.pl?node_id=153814">Mastering Perl/Tk</A><BR><A HREF="http://perlmonks.org/index.pl?node_id=154071">Style geekcode</A><BR><A HREF="http://perlmonks.org/index.pl?node_id=152489">Getting Started with GnuPG and GPG</A><BR><A HREF="http://perlmonks.org/index.pl?node_id=157018">Private Class Methods</A><BR><A HREF="http://perlmonks.org/index.pl?node_id=31148">BastardOperator</A><BR><A HREF="http://perlmonks.org/index.pl?node_id=153046">Professional Employees and Works for Hire</A><BR><A HREF="http://perlmonks.org/index.pl?node_id=17251">MeowChow</A><BR><A HREF="http://perlmonks.org/index.pl?node_id=25727">kilinrax</A><BR><A HREF="http://perlmonks.org/index.pl?node_id=157450">Subterfuge for Linux</A><BR><A HREF="http://perlmonks.org/index.pl?node_id=157626">Procmail+Pine spam filtering</A><BR><A HREF="http://perlmonks.org/index.pl?node_id=158006">Program configuration in the OOP world</A><BR><A HREF="http://perlmonks.org/index.pl?node_id=158555">Google - tastic!</A><BR><A HREF="http://perlmonks.org/index.pl?node_id=158999">How to make a CPAN Module Distribution</A><BR><A HREF="http://perlmonks.org/index.pl?node_id=159382">Need help with Net::IRC</A><BR><A HREF="http://perlmonks.org/index.pl?node_id=14909">ybiC</A>
<br /><a HREF="/index.pl?node_id=168533">Calling variable in dynamically named packages</a>
<br /><a HREF="/index.pl?node_id=170930">Re: @_ still mystifies me</a>
<br /><a HREF="/index.pl?node_id=171968">Second rate programmers and my confession</a>
<br /><a HREF="/index.pl?node_id=89965">crowflight.plx -- Any Monks in Range?</a>
<br /><a HREF="/index.pl?node_id=173030">Version Control in Database Applications</a>
<br /><a HREF="/index.pl?node_id=174082">Automated software testing: emulation of interfaces using Test::MockObject</a>
<br /><a HREF="/index.pl?node_id=174082">Automated software testing: emulation of interfaces using Test::MockObject</a>
<br /><a HREF="/index.pl?node_id=171725">Fame, Fortune, ChicksStuds, and XP!</a>
<br /><a HREF="/index.pl?node_id=177753">Module writing hints?</a>
<br /><a HREF="/index.pl?node_id=106756">Where do you turn for programming inspiration?</a>
<br /><a HREF="/index.pl?node_id=151506">Where the inspiration comes from ?</a>
<br /><a HREF="/index.pl?node_id=184523">Inspiration comes to the inspirable?</a>
<br /><a HREF="/index.pl?node_id=186111">Submitting A Module To CPAN</a>
<br /><a HREF="/index.pl?node_id=191366">Put yourself on the Map -- correction</a>
<br /><a HREF="/index.pl?node_id=199480">Collaborative Learning Project officially opens</a>
<br /><a HREF="/index.pl?node_id=200905">Perl contract problems</a>
<br /><a HREF="/index.pl?node_id=184509">How can I stop ARGV from globbing all over the place?</a>
<br /><a HREF="/index.pl?node_id=69394">cacharbe</a>
<br /><a HREF="/index.pl?node_id=109068">Why I hate File::Find and how I (hope I) fixed it</a>
<br /><a HREF="/index.pl?node_id=158096">Passing arguments to File::Find</a>
<br /><a HREF="/index.pl?node_id=109068">Why I hate File::Find and how I (hope I) fixed it</a>
<br /><a HREF="/index.pl?node_id=158096">Passing arguments to File::Find</a>
<br /><a HREF="/index.pl?node_id=213108">The Lego approach</a>
<br /><a HREF="/index.pl?node_id=213442">Is Perl 6 dead?</a>
<br /><a HREF="/index.pl?node_id=213523">Re: Perl oo vs plain Perl</a>
<br /><a HREF="/index.pl?node_id=214337">evolving an OO design</a>
<br /><a HREF="/index.pl?node_id=66160">Tk tutorials for Perl</a>
<br /><a HREF="/index.pl?node_id=54829">Perl/Tk</a>
<br /><a HREF="/index.pl?node_id=88464">Tk Tutorial</a>
<br /><a HREF="/index.pl?node_id=216602">Perl cheat sheet</a>
<br /><a HREF="/index.pl?node_id=216762">RegexLab (a wxPerl version)</a>
<br /><a HREF="/index.pl?node_id=217122">Evolution, v2.0</a>
<br /><a HREF="/index.pl?node_id=216985">"safe" perl cron environment?</a>
<br /><a HREF="/index.pl?node_id=218729">MOPT-01 - assumptions and spaces</a>
<br /><a HREF="/index.pl?node_id=121443">Perl with XML</a>
<br /><a HREF="/index.pl?node_id=194839">(OT) Interview questions -- your response?</a>
<br /><a HREF="/index.pl?node_id=134687">Technical Interview</a>
<br /><a HREF="/index.pl?node_id=53470">Interview questions</a>
<br /><a HREF="/index.pl?node_id=165743">cvs daemon in perl</a>
<br /><a HREF="/index.pl?node_id=228556">Open Source, Publications, and Resumes</a>
<br /><a HREF="/index.pl?node_id=242033">Searching locally with Perlfect with Monkey Httpd</a>
<br /><a HREF="/index.pl?node_id=110829">Finding last added auto_increment id in mysql</a>
<br /><a HREF="/index.pl?node_id=110829">Finding last added auto_increment id in mysql</a>
<br /><a HREF="/index.pl?node_id=247441">Easy dispatch tables.</a>
<br /><a HREF="/index.pl?node_id=247538">Host status icon (Win32)</a>
<br /><a HREF="/index.pl?node_id=247591">Learning regexes</a>
<br /><a HREF="/index.pl?node_id=247543">Closing Perl Source</a>
<br /><a HREF="/index.pl?node_id=247849">Donation Tracking "Thermometer"</a>
<br /><a HREF="/index.pl?node_id=248328">Find Location Of Hometown</a>
<br /><a HREF="/index.pl?node_id=33410">sexeger</a>
<br /><a HREF="/index.pl?node_id=254047">Developer Accountability</a>
<br /><a HREF="/index.pl?node_id=256410">Brain Break</a>
<br /><a HREF="/index.pl?node_id=257484">requirement documents?</a>
<br /><a HREF="/index.pl?node_id=257782">Vim for Perl developers</a>
<br /><a HREF="/index.pl?node_id=262049">Freelancing advice?</a>
<br /><a HREF="/index.pl?node_id=262313">Perl Testing and Quality Assurance</a>
<br /><a HREF="/index.pl?node_id=26176">Converting shell wildcards into regular expressions</a>
<br /><a HREF="/index.pl?node_id=92108">Convert glob notation to regular expression</a>
<br /><a HREF="/index.pl?node_id=268689">Useful non-Perl-specific references</a>
<br /><a HREF="/index.pl?node_id=273738">PerlMonks MUD in progress</a>
<br /><a HREF="/index.pl?node_id=95246">The Perl Compiler (turning perl scripts into binary executables)</a>
<br /><a HREF="/index.pl?node_id=278129">Project Management</a>
<br /><a HREF="/index.pl?node_id=280268">Autogenerate Test Scripts</a>
<br /><a HREF="/index.pl?node_id=281897">SSL certificate generator</a>
<br /><a HREF="/index.pl?node_id=283594">cpan-upload</a>
<br /><a HREF="/index.pl?node_id=288022">Things you need to know before programming Perl ithreads</a>
<br /><a HREF="/index.pl?node_id=288332">Tree::DAG_Node</a>
<br /><a HREF="/index.pl?node_id=291784">Using LWP::Simple with a callback (progress indicator)</a>
<br /><a HREF="/index.pl?node_id=291838">Monitor Bandwidth on an Interface</a>
<br /><a HREF="/index.pl?node_id=292625">Combine LWP::Simple with XML::LibXML to download go exercises</a>
<br /><a HREF="/index.pl?node_id=301803">cpandiff - diff local source against CPAN</a>
<br /><a HREF="/index.pl?node_id=302259">An internet garbage filter</a>
<br /><a HREF="/index.pl?node_id=306063">Why use threads over processes, or why use processes over threads?</a>
<br /><a HREF="/index.pl?node_id=313934">SQL Crosstab, a hell of a DBI idiom</a>
<br /><a HREF="/index.pl?node_id=237040">PerlMonks FAQ</a>
<br /><a HREF="/index.pl?node_id=323567">Learning from Obfuscation</a>
<br /><a HREF="/index.pl?node_id=326134">This looks like someone sneezed and hit the keyboard</a>
<br /><a HREF="/index.pl?node_id=326458">OT: Ways of managing changes to a database's structure during a project.</a>
<br /><a HREF="/index.pl?node_id=334151">Submit scripts and support site.</a>
<br /><a HREF="/index.pl?node_id=341329">Testaholics Anonymous (or how I learned to stop worrying and love Test::More)</a>
<br /><a HREF="/index.pl?node_id=126575">programatically setting the LD_LIBRARY_PATH</a>
<br />[id://377068]
<br />[id://402070]
<br />[id://423100]
<br />[id://429375]
<br />[id://430374]
<br />[id://443815]
<br />[id://461780]
<br />[id://461780]
<br />[id://492932]
<br />[id://494115]
<br />[id://494115]
<br />[id://442755]
<br />[id://542143]
<br />[id://546876]
<br />[id://548234]
<br />[id://417429]
<br />[id://560490]
<br />[id://567411]
<br />[id://584790]
<br />[id://603088]
<br />[id://604590]
<br />[id://607556]