#!/usr/bin/perl -T
use strict;
use warnings;
use Carp;
use Data::Dumper;
use lib qw{/home/hesco/sandbox/Politics-VoterContact-PhoneBank/lib};
use Politics::VoterContact::PhoneBank::DB;
use Politics::VoterContact::WWW::Dashboard2;
my %defaults = (
config_file => '/home/hesco/sandbox/Politics-VoterContact-PhoneBank/t/conf.d/pb-ListCheckOut_same_db_off.ini',
);
my $pb = Politics::VoterContact::WWW::Dashboard2->new(\%defaults);
my $params = $pb->{'q'}->Vars;
print STDERR "The cgi script says form gave us: \n" . Dumper(\$params);
my ($hh_values);
if($pb->{'q'}->param('_submit') eq 'Proceed to Next Household'){
$pb->_record_call_results($params);
$hh_values = $pb->_obtain_next_household();
print STDERR "The cgi scripts says \$hh_values is: " . Dumper(\$hh_values);
$pb->{'q'}->delete('_submit');
$pb->{'q'}->delete('_submitted_phone_canvas_household');
} elsif(!$pb->{'q'}->param('_submitted_phone_canvas_household')){
$hh_values = $pb->_obtain_next_household();
print STDERR "The cgi scripts says \$hh_values is: " . Dumper(\$hh_values);
}
my $html = $pb->_render_online_household_form($hh_values);
print STDERR "We made it back to cgi script.\n";
if(defined($html)){
# print STDERR "canvas_hh_screen.cgi says that \$html is: $html \n";
print $html;
} else {
print STDERR "\$html remains undefined for some reason.\n";
}
1;
####
sub _render_online_household_form {
my $self = shift;
my $hh_values = shift;
my $form = CGI::FormBuilder->new(
name => 'phone_canvas_household',
method => 'post',
stylesheet => '',
values => $hh_values,
title => 'Phone Canvas a Household',
submit => ['Reset this Household', 'Proceed to Next Household','Save Results'],
keep_extras => 1,
sticky => 1,
);
my $mode;
if(defined($hh_values->{'hh_id'})){
my $mode = $form->cgi_param('mode') || 'canvas';
} else {
$hh_values = $self->_obtain_next_household();
$form->cgi_param( name => 'mode', value => 'next_hh' );
}
# lots of form field definition statements
if($mode eq 'canvas'){
print STDERR "Our mode is 'canvas'. \n";
if($form->submitted && $form->validate){
my $field = $form->fields;
if($form->submitted eq 'Proceed to Next Household'){
print STDERR "\$form->submitted is now: " . $form->submitted . "\n";
$self->_record_call_results($field);
my %field_options = (
name => 'mode',
type => 'hidden',
value => 'next_hh',
);
$form->field( \%field_options );
$www_hh_form = $form->render(header => 1);
# $www_hh_form .= "" . Dumper(\$field) . "
";
return $www_hh_form;
} elsif($form->submitted eq 'Save Results') {
$self->_record_call_results($field);
# $www_hh_form = $form->confirm(header => 1);
$www_hh_form = $self->_render_dashboard();
$www_hh_form .= "" . Dumper(\$field) . "
";
print STDERR "\$form->submitted is now: " . $form->submitted . "\n";
return $www_hh_form;
} elsif($form->submitted eq 'Reset this Household') {
my $record_count = $self->_reset_hh_call_results($field);
$www_hh_form = $form->render(header => 1);
print STDERR "\$form->submitted is now: " . $form->submitted . "\n";
return $www_hh_form;
} else {
print STDERR "Form invoked with illegal submit button from IP: \n";
die "Form invoked with illegal submit button from IP: \n";
}
} else {
print STDERR "OK, we'll render form for first time for this household.\n";
print STDERR "\$form->submitted is now: " . $form->submitted . "\n";
$www_hh_form = $form->render(header => 1);
return $www_hh_form;
}
} elsif($mode eq 'next_hh'){
print STDERR "Our mode is 'next_hh'. \n";
$self->_obtain_next_household();
my %field_options = (
name => 'mode',
type => 'hidden',
value => 'canvas',
);
$form->field( \%field_options );
}
}
####
[Wed May 14 21:03:31 2008] [error] [client 127.0.0.1] line 185 of ->_obtain_next_household() checked out record with code: Now Assigned.
[Wed May 14 21:03:32 2008] [error] [client 127.0.0.1] Our mode is 'canvas'.
[Wed May 14 21:03:32 2008] [error] [client 127.0.0.1] OK, we'll render form for first time for this household.
[Wed May 14 21:03:32 2008] [error] [client 127.0.0.1] $form->submitted is now: 0
[Wed May 14 21:03:32 2008] [error] [client 127.0.0.1] We made it back to cgi script.
####
[Wed May 14 21:07:15 2008] [error] [client 127.0.0.1] line 185 of ->_obtain_next_household() checked out record with code: Now Assigned., referer: http://localhost/cgi-bin/canvas_hh_screen.cgi
[Wed May 14 21:07:16 2008] [error] [client 127.0.0.1] Our mode is 'canvas'. , referer: http://localhost/cgi-bin/canvas_hh_screen.cgi
[Wed May 14 21:07:16 2008] [error] [client 127.0.0.1] $form->submitted is now: Proceed to Next Household, referer: http://localhost/cgi-bin/canvas_hh_screen.cgi
[Wed May 14 21:07:16 2008] [error] [client 127.0.0.1] ->_record_call_results() says: $VAR1 = \\{, referer: http://localhost/cgi-bin/canvas_hh_screen.cgi
[Wed May 14 21:07:16 2008] [error] [client 127.0.0.1] 'h_4380' => {,
. . . followed by a Data::Dumper hash for the subsequent household, . . .
[Wed May 14 21:07:16 2008] [error] [client 127.0.0.1] $list->_CheckInRecord_VoterID() says that $args consists of: $VAR1 = \\{, referer: http://localhost/cgi-bin/canvas_hh_screen.cgi
. . . where it attempts to checkin the new record, not the just completed one . . .
[Wed May 14 21:07:16 2008] [error] [client 127.0.0.1] };, referer: http://localhost/cgi-bin/canvas_hh_screen.cgi
[Wed May 14 21:07:16 2008] [error] [client 127.0.0.1] We made it back to cgi script., referer: http://localhost/cgi-bin/canvas_hh_screen.cgi
####
#!/usr/bin/perl -T
use strict;
use warnings;
use Carp;
use Data::Dumper;
use lib qw{/home/hesco/sandbox/Politics-VoterContact-PhoneBank/lib};
use Politics::VoterContact::PhoneBank::DB;
use Politics::VoterContact::WWW::Dashboard;
my %defaults = (
config_file => '/home/hesco/sandbox/Politics-VoterContact-PhoneBank/t/conf.d/pb-ListCheckOut_same_db_off.ini',
);
my $dashboard = Politics::VoterContact::WWW::Dashboard->new(\%defaults);
# my $html = $dashboard->_process_list_of_households();
my $hh_values = $dashboard->_obtain_next_household();
my $html = $dashboard->_render_online_household_form($hh_values);
print STDERR "We made it back to cgi script.\n";
if(defined($html)){
# print STDERR "canvas_hh_screen.cgi says that \$html is: $html \n";
print $html;
} else {
print STDERR "\$html remains undefined for some reason.\n";
}
1;