NAME

Business::ISP::GUI::Accounting - This module is the complete web GUI for the ISP accounting system.

VERSION

SYNOPSIS

# In the CGI script visible to the web server (accounting.cgi)

use Business::ISP::GUI::Accounting;
my $gui = Business::ISP::GUI::Accounting->new();
$gui->run();

DESCRIPTION

This module is responsible for generating HTML pages and providing API's for all operations relating to the ISP Accounting web GUI.

METHODS

setup ()

Initializes an empty CGI::Application, defines the run modes, and sets the starting run mode.

The mode parameter for this module is 'do'.

Takes no arguments, and there is no return.

home (USERNAME)

Generates the users plan information that is included in each accounting web page.

If the optional scalar string USERNAME is not supplied, we will look for it within any incoming CGI parameters. If both fail, we will default to supplying a text box where the operator can enter the USERNAME in directly.

This method MUST call $self->_header() and $self->_footer(). It SHOULD call $self->_client_info_table().

show_plan

Displays the details of the current user's plan. Takes no params, there is no return.

display_add_plan

Provides an input form for the addition of a new plan for the current user.

Takes no params, returns to the add_plan template.

add_plan

Sends the collected new plan data into User for verification.

Takes no params, there is no return.

display_purchase_form

Generates the payment form

Takes no parameters. All parameters are passed in via CGI. Returns the pb_build.

This method MUST call $self->_header() and $self->_footer(). It SHOULD call $self->_client_info_table().

process_purchase

This method takes the input from the display_purchase_form(), and hands off to Business::ISP::Transac for final processing.

display_payment_form

Generates the payment form.

Takes no parameters. All parameters are passed in via CGI. Returns the pb_build.

This method MUST call $self->_header() and $self->_footer(). It SHOULD call $self->_client_info_table().

process_payment ()

This method takes the input from the display_payment_form(), and hands off to Business::ISP::Transac for final processing.

_process(\%DATA)

This method is used for processing items that require error checking, and for finalizing the data before it is passed back to the calling CGI. It takes care of returning either the populated error template or the successful template to the calling CGI.

DATA is an optional hashref parameter of the data you want inserted into the error page template.

Returns either a rendered Business::ISP::Error page template, or a pb_build.

If called in list context, this method will skip processing the success template and return control to the calling method. Otherwise, you signify that you are done, and want the return to be sent to the calling CGI.

_render_error ()

Builds and creates the HTML template that displays the error messages via the template.

Uses Business::ISP::Error->render_gui_data() to format the data for the template.

initialize_credit_payment ( NAME => VALUE )

Reusable method to instantiate a credit card transaction. Calls process_bank_response().

The two mandatory parameters are:

-amount => float
-error  => Business::ISP::Error object

Returns success (0) if everything went properly and 1 if not.

process_bank_response ( BANK_RESPONSE )

Reusable method that takes the array provided by calling Business::ISP::Transac->credit_card_payment() as it's only mandatory parameter.

Returns/renders to the GUI immediately if the transaction failed, thereby halting the rest of the transaction processing.

Returns 0/success if the transac succeeded, and 1 if not. The page builder params are updated with specific information returned from the bank.

Which data this is, is dependent on whether the bank returned success or failure.

_header ()

Generates the header to be printed at the top of the web page, and opens the HTML tags.

Takes no parameters, there is no return.

Generates the footer to be printed at the bottom of the web page. It also closes out the HTML tags.

Takes no parameters, there is no return.

_client_info_table (USERNAME)

Generates the users plan information that is included in each accounting web page.

The mandatory parameter USERNAME is an Business::ISP::User object.

_contact_info_table (USERNAME)

Generates the users contact-type information. This method is only called by _client_info_table(), and will only print this table if run mode is 'home', and it is not disabled in the config.

The mandatory parameter USERNAME is an Business::ISP::User object. There is no return.

_clear_session ( { NAME => VALUE } )

Clears the current operators session.

Takes an optional hash reference as a parameter:

{ only_save_profile => 1 }

If set, all collected session parameters are cleared except the operators profile. Otherwise, the 'username' parameter will be retained along with the profile.

Returns 0 upon completion.

_session_extract( FIELD_NAME, DELETE_AFTER )

Extracts a data structure from a session. Created originally to be called by the individual report subs, it can extend beyond that.

FIELD_NAME is the name of the session data structure to retrieve, and is a mandatory scalar string parameter.

DELETE_AFTER is an optional parameter. If set to true, the named session variable will be deleted from the session after the data has been extracted.

Returns a data structure. It is up to the caller to know/deal with what type of data structure is returned.

_write_protected ({ error => ERROR })

This method is called from all operations that have the potential to attempt write operations on the database when the master database server is locked out while in maintenance mode.

It is responsible for generating relevant error messages.

The parameters are passed in within a hash reference. ERROR is an Business::ISP::Error object, and is mandatory.

Returns the Business::ISP::Error object. It is the responsibility of the caller to act on it.

income_by_payment_type()

Reports income per day, sorted by payment method.

AUTHOR

Steve Bertrand, <steveb at cpan.org>

BUGS

Report bugs to <steveb at cpan.org>. I will be notified, and will report back to you with any updates.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Business::ISP::GUI::Accounting

COPYRIGHT & LICENSE

Copyright 2012 Steve Bertrand, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.