App-Office-Contacts-Donations

 view release on metacpan or  search on metacpan

lib/App/Office/Contacts/Donations/Controller.pm  view on Meta::CPAN

	# Set up the view.

	$self -> param(view => App::Office::Contacts::Donations::View -> new
	(
		db          => $self -> param('db'),
		script_name => $self -> script_name,
		session     => $self -> param('session'),
		tmpl_path   => $self -> tmpl_path,
	) );

	if ($self -> validate_post == 0)
	{
		$self -> prerun_mode('Initialize');
	}

} # End of cgiapp_prerun.

# -----------------------------------------------

1;

lib/App/Office/Contacts/Donations/Controller/Initialize.pm  view on Meta::CPAN


# -----------------------------------------------

sub display
{
	my($self)        = @_;
	my($cookie_name) = 'donations';

	$self -> log(debug => 'Entered display');

	return 'Invalid cookie digest' if ($self -> validate_post($cookie_name) == 0);

	$self -> generate_cookie($cookie_name);

	return $self -> build_web_page;

} # End of display.

# -----------------------------------------------

1;

lib/App/Office/Contacts/Donations/Database/Util.pm  view on Meta::CPAN

sub get_donation_projects
{
	my($self) = @_;

	return $self -> select_map('select name, id from donation_projects');

} # End of get_donation_projects.

# --------------------------------------------------

sub validate_currency
{
	my($self, $value) = @_;

	return 1;

} # End of validate_currency.

# --------------------------------------------------

sub validate_donation_motive
{
	my($self, $value) = @_;

	return 1;

} # End of validate_donation_motive.

# --------------------------------------------------

sub validate_donation_project
{
	my($self, $value) = @_;

	return 1;

} # End of validate_donation_project.

# --------------------------------------------------

sub validate_report
{
	my($self, $value) = @_;
	my($id)           = $self -> db -> dbh -> selectrow_hashref('select id from reports where id = ?', {}, $value);

	return $id ? $$id{'id'} : 0;

} # End of validate_report.

# --------------------------------------------------

sub validate_report_entity
{
	my($self, $value) = @_;
	my($id)           = $self -> db -> dbh -> selectrow_hashref('select id from report_entities where id = ?', {}, $value);

	return $id ? $$id{'id'} : 0;

} # End of validate_report_entity.

# --------------------------------------------------

__PACKAGE__ -> meta -> make_immutable;

1;

lib/App/Office/Contacts/Donations/View/Role/Report.pm  view on Meta::CPAN

		for my $field_name ($user_data -> valids)
		{
			$$input{$field_name} = $user_data -> get_value($field_name) || '';
		}
	}
	else
	{
		return {error => {type => 'Invalid report options'} };
	}

	my($from_date, $to_date)    = $self -> validate_date_range($$input{'date_range'});
	my($donation)               = $self -> db -> dbh -> selectall_arrayref('select * from donations', {Slice => {} }) || [];
	my($organizations_table_id) = ${$self -> db -> util -> table_map}{'organizations'}{'id'};
	my($people_table_id)        = ${$self -> db -> util -> table_map}{'people'}{'id'};
	my($report_entity)          = $self -> db -> util -> get_report_entities;
	my($organization_entity)    = $$report_entity{'Organizations'};
	my($people_entity)          = $$report_entity{'People'};

	my($broadcast_id);
	my($communication_type_id);
	my($gender_id);

lib/App/Office/Contacts/Donations/View/Role/Report.pm  view on Meta::CPAN


		$result = $self -> build_report_by_amount(\@item, $organizations_table_id, $people_table_id);
	}

	return $result;

} # End of generate_donation_total_report.

# -----------------------------------------------

sub validate_date_range
{
	my($self, $date_range) = @_;
	my($today)     = Date::Simple::today();
	my(@ymd)       = $today -> as_ymd();
	$ymd[2]        = 1;
	my($first_day) = Date::Simple::ymd(@ymd);
	my($day_count) = Date::Simple::days_in_month($ymd[0], $ymd[1]);
	$ymd[2]        = $day_count;
	my($last_day)  = Date::Simple::ymd(@ymd);
	$date_range    = '' if (! $date_range);

lib/App/Office/Contacts/Donations/View/Role/Report.pm  view on Meta::CPAN

	my(@field);

	if ($date_range =~ /(\d{4}-\d{1,2}-\d{1,2})\.(\d{4}-\d{1,2}-\d{1,2})/)
	{
		$field[0] = $1;
		$field[1] = $2;
	}

	my($from_date) = Date::Simple::date($field[0]) || $first_day;
	my($to_date)   = Date::Simple::date($field[1]) || $last_day;
	$from_date     = $self -> validate_digit_count($from_date);
	$to_date       = $self -> validate_digit_count($to_date);

	return ("$from_date 00:00:00", "$to_date 23:59:59");

} # End of validate_date_range.

# -----------------------------------------------
# Javascript returns the 1st December as 2008-12-1, not -01.

sub validate_digit_count
{
	my($self, $date) = @_;
	my(@ymd) = split(/-/, $date);
	$ymd[1]  = "0$ymd[1]" if (length($ymd[1]) == 1);
	$ymd[2]  = "0$ymd[2]" if (length($ymd[2]) == 1);

	return "$ymd[0]-$ymd[1]-$ymd[2]";

} # End of validate_digit_count.

# -----------------------------------------------

no Moose::Role;

1;



( run in 0.244 second using v1.01-cache-2.11-cpan-4d50c553e7e )