summaryrefslogtreecommitdiff
path: root/httemplate/elements
diff options
context:
space:
mode:
authorivan <ivan>2006-05-07 20:27:21 +0000
committerivan <ivan>2006-05-07 20:27:21 +0000
commite65c6a26ca778166aec2b2d1dd3012ab84fa611a (patch)
tree1ef2a5a21088301217a8b4f1440fedd6b7b1a274 /httemplate/elements
parent29644d5921c99520965b884b25800ed084891e94 (diff)
first pass at sales reports per agent and package class
Diffstat (limited to 'httemplate/elements')
-rw-r--r--httemplate/elements/select-month_year.html19
-rw-r--r--httemplate/elements/select-pkg_class.html7
-rw-r--r--httemplate/elements/select-table.html11
-rw-r--r--httemplate/elements/tr-select-from_to.html51
-rw-r--r--httemplate/elements/tr-select-pkg_class.html15
5 files changed, 83 insertions, 20 deletions
diff --git a/httemplate/elements/select-month_year.html b/httemplate/elements/select-month_year.html
index a0ea74ddd..2866960bd 100644
--- a/httemplate/elements/select-month_year.html
+++ b/httemplate/elements/select-month_year.html
@@ -5,13 +5,22 @@
my $prefix = $opt{'prefix'} || '';
my $disabled = $opt{'disabled'} || '';
my $empty = $opt{'empty_option'} || '';
+ my $start_year = $opt{'start_year'};
+ my $end_year = $opt{'end_year'} || '2037';
+
+ my @mon;
+ if ( $opt{'show_month_abbr'} ) {
+ @mon = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
+ } else {
+ @mon = ( 1 .. 12 );
+ }
+
my $date = $opt{'selected_date'} || '';
$date = '' if $date eq '-';
#$date ||= '01-2000' unless $empty;
- my $start_year = $opt{'start_year'};
- my $end_year = $opt{'end_year'} || '2037';
- my( $mon, $year ) = (0, 0);
+ my $mon = $opt{'selected_mon'} || 0;
+ my $year = $opt{'selected_year'} || 0;
if ( $date ) {
if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
( $mon, $year ) = ( $2, $1 );
@@ -34,8 +43,8 @@
<%= $empty ? '<OPTION VALUE="">' : '' %>
-<% for ( 1 .. 12 ) { %>
- <OPTION<%= $_ == $mon ? ' SELECTED' : '' %> VALUE="<%= $_ %>"><%= $_ %>
+<% foreach ( 1 .. 12 ) { %>
+ <OPTION<%= $_ == $mon ? ' SELECTED' : '' %> VALUE="<%= $_ %>"><%= $mon[$_-1] %>
<% } %>
</SELECT>/<SELECT NAME="<%= $prefix %>_year" SIZE="1" <%= $disabled%>>
diff --git a/httemplate/elements/select-pkg_class.html b/httemplate/elements/select-pkg_class.html
index 5486e0877..032c7abda 100644
--- a/httemplate/elements/select-pkg_class.html
+++ b/httemplate/elements/select-pkg_class.html
@@ -1,16 +1,17 @@
<%
my( $classnum, %opt ) = @_;
- my %select_opt = ();
- $select_opt{'records'} = $opt{'pkg_class'}
+ $opt{'records'} = delete $opt{'pkg_class'}
if $opt{'pkg_class'};
+ #warn "***** select-pkg-class: \n". Dumper(%opt);
+
%><%= include( '/elements/select-table.html',
'table' => 'pkg_class',
'name_col' => 'classname',
'value' => $classnum,
'empty_label' => '(none)',
#'hashref' => { 'disabled' => '' },
- #%select_opt,
+ %opt,
)
%>
diff --git a/httemplate/elements/select-table.html b/httemplate/elements/select-table.html
index 10cc8b995..96f0177fb 100644
--- a/httemplate/elements/select-table.html
+++ b/httemplate/elements/select-table.html
@@ -11,9 +11,12 @@
# 'empty_label' => '', #better specify it though, the default might change
# 'hashref' => {},
# 'records' => \@records, #instead of hashref
+ # 'pre_options' => [ 'value' => 'option' ], #before normal options
my( %opt ) = @_;
+ #warn "***** select-table: \n". Dumper(%opt);
+
my $key = dbdef->table($opt{'table'})->primary_key; #? $opt{'primary_key'} ||
my $name_col = $opt{'name_col'};
@@ -25,11 +28,17 @@
@records = qsearch( $opt{'table'}, ( $opt{'hashref'} || {} ) );
}
+ my @pre_options = $opt{'pre_options'} ? @{ $opt{'pre_options'} } : ();
+
%>
<SELECT NAME="<%= $key %>">
- <OPTION VALUE=""><%= $opt{'empty_label'} || 'all' %></OPTION>
+ <% while ( @pre_options ) { %>
+ <OPTION VALUE="<%= shift(@pre_options) %>"><%= shift(@pre_options) %>
+ <% } %>
+
+ <OPTION VALUE=""><%= $opt{'empty_label'} || 'all' %>
<% foreach my $record ( sort { $a->$name_col() cmp $b->$name_col() }
@records
diff --git a/httemplate/elements/tr-select-from_to.html b/httemplate/elements/tr-select-from_to.html
new file mode 100644
index 000000000..d7e5a8337
--- /dev/null
+++ b/httemplate/elements/tr-select-from_to.html
@@ -0,0 +1,51 @@
+<%
+
+ #my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
+ my ($curmon,$curyear) = (localtime(time))[4,5];
+
+ #find first month
+ my $syear = 1899+$curyear;
+ my $smonth = $curmon+1;
+
+ #want 12 month by default, not 13
+ $smonth++;
+ if ( $smonth > 12 ) { $smonth-=12; $syear++ }
+
+ #find last month
+ my $eyear = 1900+$curyear;
+ my $emonth = $curmon+1;
+
+ my %hash = (
+ 'show_month_abbr' => 1,
+ 'start_year' => '1999',
+ 'end_year' => '2012', #haha, well...
+ @_,
+ );
+
+%>
+
+<TR>
+ <TD ALIGN="right">From: </TD>
+ <TD>
+ <%= include('/elements/select-month_year.html',
+ 'prefix' => 'start',
+ 'selected_mon' => $smonth,
+ 'selected_year' => $syear,
+ %hash,
+ )
+ %>
+ </TD>
+</TR>
+
+<TR>
+ <TD ALIGN="right">To: </TD>
+ <TD>
+ <%= include('/elements/select-month_year.html',
+ 'prefix' => 'end',
+ 'selected_mon' => $emonth,
+ 'selected_year' => $eyear,
+ %hash,
+ )
+ %>
+ </TD>
+</TR>
diff --git a/httemplate/elements/tr-select-pkg_class.html b/httemplate/elements/tr-select-pkg_class.html
index de10885c8..fbab0db14 100644
--- a/httemplate/elements/tr-select-pkg_class.html
+++ b/httemplate/elements/tr-select-pkg_class.html
@@ -1,16 +1,12 @@
<%
my( $classnum, %opt ) = @_;
- my @pkg_class;
- if ( $opt{'pkg_class'} ) {
- @pkg_class = @{ $opt{'pkg_class'} };
- } else {
- @pkg_class = qsearch( 'pkg_class', {} ); # { disabled=>'' } );
- }
+ $opt{'pkg_class'} ||= [ qsearch( 'pkg_class', {} ) ]; # { disabled=>'' } )
+ #warn "***** tr-select-pkg-class: \n". Dumper(%opt);
%>
-<% if ( scalar(@pkg_class) == 0 ) { %>
+<% if ( scalar(@{ $opt{'pkg_class'} }) == 0 ) { %>
<INPUT TYPE="hidden" NAME="classnum" VALUE="">
@@ -19,10 +15,7 @@
<TR>
<TD ALIGN="right"><%= $opt{'label'} || 'Package class' %></TD>
<TD>
- <%= include( '/elements/select-pkg_class.html', $classnum,
- 'pkg_class' => \@pkg_class,
- )
- %>
+ <%= include( '/elements/select-pkg_class.html', $classnum, %opt ) %>
</TD>
</TR>