[Astpp-commit] SF.net SVN: astpp:[2295] trunk
Brought to you by:
darrenkw
From: <dar...@us...> - 2009-10-31 23:51:51
|
Revision: 2295 http://astpp.svn.sourceforge.net/astpp/?rev=2295&view=rev Author: darrenkw Date: 2009-10-31 23:51:38 +0000 (Sat, 31 Oct 2009) Log Message: ----------- Add the first revision of the tax handling interface. Add support to perform regex commands on accountcodes prior to rating as per http://www.astpp.org/?q=node/261 Modified Paths: -------------- trunk/scripts/astpp-common.pl trunk/web_interface/astpp-admin.cgi Added Paths: ----------- trunk/templates/taxes.tpl Modified: trunk/scripts/astpp-common.pl =================================================================== --- trunk/scripts/astpp-common.pl 2009-10-28 01:21:43 UTC (rev 2294) +++ trunk/scripts/astpp-common.pl 2009-10-31 23:51:38 UTC (rev 2295) @@ -4249,6 +4249,9 @@ $cdrinfo->{accountcode} = $record->{account}; $cdrinfo->{dst} = $did; } + if ($config->{cdr_regex_accountcode}) { + $cdrinfo->{accountcode} =~ $config->{cdr_regex_accountcode}; + } my $carddata = &get_account( $astpp_db, $cdrinfo->{accountcode} ); if ($carddata->{number}) { Added: trunk/templates/taxes.tpl =================================================================== --- trunk/templates/taxes.tpl (rev 0) +++ trunk/templates/taxes.tpl 2009-10-31 23:51:38 UTC (rev 2295) @@ -0,0 +1,53 @@ +<table class="default"> + <tr class="header"> + <td colspan=10 align="center">Tax Details</td> +<input name="mode" value="Taxes" type="hidden"> + </tr> + <tr class="header"> + <td>ID</td> + <td>Priority</td> + <td>Amount</td> + <td>Rate</td> + <td>Description</td> + <td>Modified</td> + <td>Created</td> + <td>Action</td> + </tr> + <tr class="header"> + <td colspan=8 align="center">Add / Edit Item</td> + </tr> + <tr class="rowone"> + <input name="taxes_id" value="<TMPL_VAR NAME="taxes_id">" type="hidden"> + <td><TMPL_VAR NAME="taxes_id"></td> + <td><input name="taxes_priority" size="4" type="text" value="<TMPL_VAR NAME="taxes_priority">"></td> + <td><input name="taxes_amount" size="20" type="text" value="<TMPL_VAR NAME="taxes_amount">"></td> + <td><input name="taxes_rate" size="20" type="text" value="<TMPL_VAR NAME="taxes_rate">"></td> + <td><input name="taxes_description" size="50" type="text" value="<TMPL_VAR NAME="taxes_description">"></td> + <td><TMPL_VAR NAME="last_modified"></td> + <td><TMPL_VAR NAME="date_added"></td> + <td><TMPL_VAR NAME="action"></td> + </tr> + <tr class="header"> + <td colspan=8>List</td> + </tr> + <TMPL_LOOP NAME="taxes_list"> + <TR> + <TD><TMPL_VAR NAME="taxes_id"></TD> + <TD><TMPL_VAR NAME="taxes_priority"></TD> + <TD><TMPL_VAR NAME="taxes_amount"></TD> + <TD><TMPL_VAR NAME="taxes_rate"></TD> + <TD><TMPL_VAR NAME="taxes_description"></TD> + <TD><TMPL_VAR NAME="last_modified"></TD> + <TD><TMPL_VAR NAME="date_added"></TD> + <TD><a href="astpp-admin.cgi?mode=Taxes&action=Delete&taxes_id=<TMPL_VAR NAME="taxes_id">">Delete</a> + <a href="astpp-admin.cgi?mode=Taxes&action=Edit&taxes_id=<TMPL_VAR NAME="taxes_id">">Edit</a></TD> + </TR> + </TMPL_LOOP> +</table> + +<table> + <tr> + <td><TMPL_VAR NAME="status"></td> + </tr> + </table> +</form> Modified: trunk/web_interface/astpp-admin.cgi =================================================================== --- trunk/web_interface/astpp-admin.cgi 2009-10-28 01:21:43 UTC (rev 2294) +++ trunk/web_interface/astpp-admin.cgi 2009-10-31 23:51:38 UTC (rev 2295) @@ -88,7 +88,7 @@ gettext("Outbound Routes"), gettext("Import Outbound Routes") ); -my @System = ( gettext("Purge Deactivated"), gettext("Configuration") ); +my @System = ( gettext("Purge Deactivated"), gettext("Configuration"), gettext("Taxes") ); my @Statistics = ( gettext("Asterisk Stats"), gettext("List Errors"), gettext("Trunk stats"), gettext("View CDRs"), @@ -478,6 +478,8 @@ if $params->{mode} eq gettext("Reseller Report"); return &build_admin_vendor_report() if $params->{mode} eq gettext("Vendor Report"); + return &build_taxes() + if $params->{mode} eq gettext("Taxes"); return gettext("Not Available!") . "\n"; } @@ -9560,6 +9562,114 @@ return $template->output; } + +sub build_taxes() { + my ( $action, @brands, $tmp, $template, @taxes_list ); + $action = "<input name=\"action\" value=\"Add Item\" type=\"submit\">"; + $template = HTML::Template->new( + filename => '/var/lib/astpp/templates/taxes.tpl', + die_on_bad_params => $config->{template_die_on_bad_params} + ); + + if ( !$params->{action} ) { $params->{action} = "List"; } + + if ( $params->{action} eq "Edit" ) { + my ($tmp,$sql); + $tmp = + "SELECT * FROM taxes WHERE taxes_id = " + . $astpp_db->quote( $params->{taxes_id} ); + + $ASTPP->debug( user => $param->{username}, debug => $tmp ); + $sql = $astpp_db->prepare($tmp); + $sql->execute; + my $tax_item = $sql->fetchrow_hashref; + $sql->finish; + + $action = "<input name=\"action\" value=\"Save Item\" type=\"submit\">"; + $template->param(taxes_id => $tax_item->{taxes_id}); + $template->param(taxes_priority => $tax_item->{taxes_priority}); + $template->param(taxes_amount => $tax_item->{taxes_amount}); + $template->param(taxes_rate => $tax_item->{taxes_rate}); + $template->param(taxes_description => $tax_item->{taxes_description}); + $template->param(last_modified => $tax_item->{last_modified}); + $template->param(date_added => $tax_item->{date_added}); + + } + elsif ( $params->{action} eq "Save Item" ) { + $tmp = + "UPDATE taxes SET " + . " taxes_priority = " + . $astpp_db->quote( $params->{taxes_priority} ) . "," + . " taxes_amount = " + . $astpp_db->quote( $params->{taxes_amount} ) . "," + . " taxes_rate = " + . $astpp_db->quote( $params->{taxes_rate} ) . "," + . " taxes_description = " + . $astpp_db->quote( $params->{taxes_description} ) . "," + . " last_modified = NOW() " + . " WHERE id = " + . $astpp_db->quote( $params->{taxes_id} ); + $ASTPP->debug( user => $param->{username}, debug => $tmp ); + if ( $astpp_db->do($tmp) ) { + $status .= "Saved Tax!"; + } + else { + $status .= "Failed to Save Tax!"; + } + $params->{action} = "List"; + } + elsif ( $params->{action} eq "Add Item" ) { + $tmp = + "INSERT INTO taxes (taxes_priority,taxes_amount,taxes_rate,taxes_description) VALUES (" + . $astpp_db->quote( $params->{taxes_priority} ) . "," + . $astpp_db->quote( $params->{taxes_amount} ) . "," + . $astpp_db->quote( $params->{taxes_rate} ) . "," + . $astpp_db->quote( $params->{taxes_description} ) . ")"; + $ASTPP->debug( user => $param->{username}, debug => $tmp ); + if ( $astpp_db->do($tmp) ) { + $status .= "Added Tax!"; + } + else { + $status .= "Failed to Add Tax!"; + } + $params->{action} = "List"; + } + elsif ( $params->{action} eq "Delete" ) { + $tmp = + "DELETE FROM taxes WHERE taxes_id = " + . $astpp_db->quote( $params->{taxes_id} ); + $ASTPP->debug( user => $param->{username}, debug => $tmp ); + if ( $astpp_db->do($tmp) ) { + $status .= "Removed Tax!"; + } + else { + $status .= "Failed to Remove Tax!"; + } + $params->{action} = "List"; + } + if ( $params->{action} eq "List" ) { + $tmp = "SELECT * FROM taxes ORDER BY taxes_priority,taxes_description"; + $ASTPP->debug( user => $param->{username}, debug => $tmp ); + my $sql = $astpp_db->prepare($tmp); + $sql->execute; + while ( my $record = $sql->fetchrow_hashref ) { + my %row; + $row{taxes_id} = $record->{taxes_id}; + $row{taxes_priority} = $record->{taxes_priority}; + $row{taxes_amount} = $record->{taxes_amount}; + $row{taxes_amount} = $record->{taxes_rate}; + $row{taxes_description} = $record->{taxes_description}; + $row{last_modified} = $record->{last_modified}; + $row{date_added} = $record->{date_added}; + push( @taxes_list, \%row ); + } + $sql->finish; + $template->param( taxes_list => \@taxes_list ); + } + $template->param(action => $action ); + return $template->output; +} + sub build_configuration() { my ( $action, @brands, @resellerlist, $tmp, $template, @configuration_list ); $action = "<input name=\"action\" value=\"Add Item\" type=\"submit\">"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |