Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

vagnerr's scratchpad

by vagnerr (Prior)
on Jun 02, 2004 at 07:13 UTC ( #359236=scratchpad: print w/replies, xml ) Need Help??

# -------------------------------------------------------------------- +--------- # 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 '-',cal +cYesterday($opts)); $template->param('period_end',join '/',reverse split '-',calcY +esterday($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 cu +rrency :) $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 mi +me name? if(open(TEST,"<".$link->[2])){ my_print("Attaching\n"); close(TEST); $msg->attach(Type =>'image/'.$ +imgtype, Path =>$link->[2], Filename=>$link->[2], #Disposition => 'inlin +e'); Disposition => 'attach +ment'); }else{ my_print("Not found, Skipped!! +\n"); } } } } if($opts{'d'}){ #debug mode my_print($msg->as_string); }else{ $msg->send(); } return 1; #stub }
<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" onselec +t="storeCaret(this);" ond blclick="storeCaret(this);" onclick="storeCaret(this);" onkeyup="store +Caret(this)"></textarea> </form> </body> </html>

Getting Started with GnuPG and GPG
Professional Employees and Works for Hire
Alternate Monk Stats Listing
Mastering Perl/Tk
Style geekcode
Getting Started with GnuPG and GPG
Private Class Methods
Professional Employees and Works for Hire
Subterfuge for Linux
Procmail+Pine spam filtering
Program configuration in the OOP world
Google - tastic!
How to make a CPAN Module Distribution
Need help with Net::IRC
Calling variable in dynamically named packages
Re: @_ still mystifies me
Second rate programmers and my confession
crowflight.plx -- Any Monks in Range?
Version Control in Database Applications
Automated software testing: emulation of interfaces using Test::MockObject
Automated software testing: emulation of interfaces using Test::MockObject
Fame, Fortune, ChicksStuds, and XP!
Module writing hints?
Where do you turn for programming inspiration?
Where the inspiration comes from ?
Inspiration comes to the inspirable?
Submitting A Module To CPAN
Put yourself on the Map -- correction
Collaborative Learning Project officially opens
Perl contract problems
How can I stop ARGV from globbing all over the place?
Why I hate File::Find and how I (hope I) fixed it
Passing arguments to File::Find
Why I hate File::Find and how I (hope I) fixed it
Passing arguments to File::Find
The Lego approach
Is Perl 6 dead?
Re: Perl oo vs plain Perl
evolving an OO design
Tk tutorials for Perl
Tk Tutorial
Perl cheat sheet
RegexLab (a wxPerl version)
Evolution, v2.0
"safe" perl cron environment?
MOPT-01 - assumptions and spaces
Perl with XML
(OT) Interview questions -- your response?
Technical Interview
Interview questions
cvs daemon in perl
Open Source, Publications, and Resumes
Searching locally with Perlfect with Monkey Httpd
Finding last added auto_increment id in mysql
Finding last added auto_increment id in mysql
Easy dispatch tables.
Host status icon (Win32)
Learning regexes
Closing Perl Source
Donation Tracking "Thermometer"
Find Location Of Hometown
Developer Accountability
Brain Break
requirement documents?
Vim for Perl developers
Freelancing advice?
Perl Testing and Quality Assurance
Converting shell wildcards into regular expressions
Convert glob notation to regular expression
Useful non-Perl-specific references
PerlMonks MUD in progress
The Perl Compiler (turning perl scripts into binary executables)
Project Management
Autogenerate Test Scripts
SSL certificate generator
Things you need to know before programming Perl ithreads
Using LWP::Simple with a callback (progress indicator)
Monitor Bandwidth on an Interface
Combine LWP::Simple with XML::LibXML to download go exercises
cpandiff - diff local source against CPAN
An internet garbage filter
Why use threads over processes, or why use processes over threads?
SQL Crosstab, a hell of a DBI idiom
PerlMonks FAQ
Learning from Obfuscation
This looks like someone sneezed and hit the keyboard
OT: Ways of managing changes to a database's structure during a project.
Submit scripts and support site.
Testaholics Anonymous (or how I learned to stop worrying and love Test::More)
programatically setting the LD_LIBRARY_PATH
Perl/Tk GUI IRC Client
The Model View Controller pattern in web applications
Annual Self Appraisal forms and all this (censored)
creating skinable Perl/Tk apps
Improving Your Ability to Estimate
How do I get good acceptance tests?
Re: Hiding your Script
Re: Hiding your Script
Web Application Security Testing
Displaying TV Listings (and no screen-scraping )
Displaying TV Listings (and no screen-scraping )
Cabal Matrix
On Finding, Hiring, Inspiring and Keeping
YAPC::Europe::2006 - The Venue & Around Birmingham
YAPC::Europe::2006 - Accommodation
PerlMonks::Mechanized (beta)
Google Earth Monks - Part II (The Code)
Give up your modules!
Recommended Reading
Perl YAPC related podcasts or presentations?
Top 10 things to read when your flight is canceled
OT: What's in your Firefox?
Log In?

What's my password?
Create A New User
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2017-01-17 12:00 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (155 votes). Check out past polls.