X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2FReport%2FTable%2FMonthly.pm;h=f4ba02008f3e83a10d21d1371c05056d65be054d;hp=9aebeee3de3e93f844943f30a8f632dffb2aca0e;hb=32365ef65ca6a40b5262cf166543b1d84c6aa57d;hpb=654234a526b5447ec02970962cccb1cf879796c8 diff --git a/FS/FS/Report/Table/Monthly.pm b/FS/FS/Report/Table/Monthly.pm index 9aebeee3d..f4ba02008 100644 --- a/FS/FS/Report/Table/Monthly.pm +++ b/FS/FS/Report/Table/Monthly.pm @@ -2,9 +2,9 @@ package FS::Report::Table::Monthly; use strict; use vars qw( @ISA ); -use Time::Local; -use FS::UID qw( dbh ); +use FS::UID qw(dbh); use FS::Report::Table; +use Time::Local qw( timelocal ); @ISA = qw( FS::Report::Table ); @@ -16,148 +16,293 @@ FS::Report::Table::Monthly - Tables of report data, indexed monthly use FS::Report::Table::Monthly; - my $report = new FS::Report::Table ( + my $report = new FS::Report::Table::Monthly ( 'items' => [ 'invoiced', 'netsales', 'credits', 'receipts', ], 'start_month' => 4, 'start_year' => 2000, 'end_month' => 4, 'end_year' => 2020, + #opt + 'agentnum' => 54 + 'refnum' => 54 + 'cust_classnum' => [ 1,2,4 ], + 'params' => [ [ 'paramsfor', 'item_one' ], [ 'item', 'two' ] ], # ... + 'remove_empty' => 1, #collapse empty rows, default 0 + 'item_labels' => [ ], #useful with remove_empty ); my $data = $report->data; -=head1 METHODS +=head1 PARAMETERS + +=head2 TIME PERIOD + +C, C, C, and C specify the date +range to be included in the report. The start and end months are included. +Each month's values are summed from midnight on the first of the month to +23:59:59 on the last day of the month. + +=head2 REPORT ITEMS + +=over 4 + +=item items: An arrayref of observables to calculate for each month. See +L for a list of observables and their parameters. + +=item params: An arrayref, parallel to C, of arrayrefs of parameters +(in paired name/value form) to be passed to the observables. + +=item cross_params: Cross-product parameters. This must be an arrayref of +arrayrefs of parameters (paired name/value form). This creates an additional +"axis" (orthogonal to the time and C axes) in which the item is +calculated once with each set of parameters in C. These +parameters are merged with those in C. Instead of being nested two +levels, C will be nested three levels, with the third level +corresponding to this arrayref. + +=back + +=head2 FILTERING + +=over 4 + +=item agentnum: Limit to customers with this agent. + +=item refnum: Limit to customers with this advertising source. + +=item cust_classnum: Limit to customers with this classnum; can be an +arrayref. + +=item remove_empty: Set this to a true value to hide rows that contain +only zeroes. The C array in the returned data will list the item +indices that are actually present in the output so that you know what they +are. Ignored if C is in effect. + +=back + +=head2 PASS-THROUGH + +C, C, and C may be specified as arrayrefs +parallel to C. Those values will be returned in C, with any +hidden rows (due to C) filtered out, which is the only +reason to do this. Now that we have C it's probably better to +use that. + +=item PROCESSING + +=item normalize: Set this to an item index to have all other items expressed +as a percentage of that one. That item will then be omitted from the output. +If the normalization item is zero in some period, all the values in that +period will be undef. + +=head1 RETURNED DATA + +The C method runs the report and returns a hashref of the following: =over 4 +=item label + +Month labels, in MM/YYYY format. + +=item speriod, eperiod + +Absolute start and end times of each month, in unix time format. + +=item items + +The values passed in as C, with any suppressed rows deleted. + +=item indices + +The indices of items in the input C list that appear in the result +set. Useful for figuring out what they are when C has deleted +some items. + +=item item_labels, colors, links - see PASS-THROUGH above + =item data -Returns a hashref of data (!! describe) +The actual results. An arrayref corresponding to C