[freeside-commits] freeside/httemplate/elements tr-select-cust-part_pkg.html, NONE, 1.1 select-cust-pkg_class.html, NONE, 1.1 select-table.html, 1.14, 1.15 select-cust-part_pkg.html, 1.3, 1.4 select-part_pkg.html, 1.3, 1.4 tr-selectmultiple-part_pkg.html, 1.3, 1.4
Ivan,,,
ivan at wavetail.420.am
Sat Mar 28 15:59:38 PDT 2009
- Previous message: [freeside-commits] freeside/httemplate/misc order_pkg.html, 1.7, 1.8 change_pkg.cgi, 1.10, 1.11 cust-part_pkg.cgi, NONE, 1.1
- Next message: [freeside-commits] freeside/FS/FS Conf.pm, 1.271, 1.272 part_pkg.pm, 1.88, 1.89
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/cvsroot/freeside/httemplate/elements
In directory wavetail.420.am:/tmp/cvs-serv18155/httemplate/elements
Modified Files:
select-table.html select-cust-part_pkg.html
select-part_pkg.html tr-selectmultiple-part_pkg.html
Added Files:
tr-select-cust-part_pkg.html select-cust-pkg_class.html
Log Message:
package selector, split by package class, RT#5077
Index: select-part_pkg.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/select-part_pkg.html,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- select-part_pkg.html 9 Feb 2009 01:49:28 -0000 1.3
+++ select-part_pkg.html 28 Mar 2009 22:59:35 -0000 1.4
@@ -22,17 +22,27 @@
'name_col' => 'pkg',
'empty_label' => 'Select package', #should this be the default?
'label_callback' => sub { shift->pkg_comment },
- 'hashref' => { 'disabled' => '' },
+ 'hashref' => \%hash,
%opt,
)
%>
<%init>
-
+
my( %opt ) = @_;
$opt{'records'} = delete $opt{'part_pkg'}
if $opt{'part_pkg'};
+my %hash = ( 'disabled' => '' );
+
+if ( exists($opt{'classnum'}) && defined($opt{'classnum'}) ) {
+ if ( $opt{'classnum'} > 0 ) {
+ $hash{'classnum'} = $opt{'classnum'};
+ } elsif ( $opt{'classnum'} eq '' || $opt{'classnum'} == 0 ) {
+ $hash{'classnum'} = '';
+ } #else -1 or not specified, all classes, so don't set classnum
+}
+
$opt{'extra_sql'} .= ' AND '. FS::part_pkg->curuser_pkgs_sql;
</%init>
Index: select-table.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/select-table.html,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- select-table.html 8 Feb 2009 02:05:25 -0000 1.14
+++ select-table.html 28 Mar 2009 22:59:35 -0000 1.15
@@ -139,7 +139,7 @@
});
}
-unless ( ! $value
+unless ( $value < 1 # !$value #ignore negatives too
or ref($value)
or ! exists( $opt{hashref}->{disabled} ) #??
or grep { $value == $_->$key() } @records
Index: tr-selectmultiple-part_pkg.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/tr-selectmultiple-part_pkg.html,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- tr-selectmultiple-part_pkg.html 1 Aug 2007 22:25:10 -0000 1.3
+++ tr-selectmultiple-part_pkg.html 28 Mar 2009 22:59:35 -0000 1.4
@@ -2,11 +2,10 @@
<TD ALIGN="right"><% $opt{'label'} || 'Packages' %></TD>
<TD>
<% include( '/elements/select-table.html',
- 'table' => 'part_pkg',
- 'name_col' => 'pkg',
- 'value' => '',
- 'empty_label' => '(none)',
- 'element_etc' => 'multiple',
+ 'table' => 'part_pkg',
+ 'name_col' => 'pkg',
+ 'disable_empty' => 1,
+ 'element_etc' => 'multiple',
%opt,
)
%>
--- NEW FILE: select-cust-pkg_class.html ---
<% include( '/elements/select-pkg_class.html',
'pre_options' => [ '-1' => 'all' ], #XXX a config ?
#'pre_options' => [ '-2' => 'Select package class' ],
'disable_empty' => 1,
%opt,
)
%>
<%init>
my %opt = @_;
</%init>
Index: select-cust-part_pkg.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/select-cust-part_pkg.html,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- select-cust-part_pkg.html 8 Feb 2009 02:05:25 -0000 1.3
+++ select-cust-part_pkg.html 28 Mar 2009 22:59:35 -0000 1.4
@@ -31,11 +31,11 @@
my $cust_main = $opt{'cust_main'}
or die "cust_main not specified";
-$opt{'extra_sql'} .=
- ' AND ( agentnum IS NOT NULL '.
- ' OR 0 < ( SELECT COUNT(*) FROM type_pkgs '.
- ' WHERE typenum = '. $cust_main->agent->typenum.
- ' AND type_pkgs.pkgpart = part_pkg.pkgpart )'.
- ' )';
+$opt{'extra_sql'} .= ' AND '. FS::part_pkg->agent_pkgs_sql( $cust_main->agent );
+# ' AND ( agentnum IS NOT NULL '.
+# ' OR 0 < ( SELECT COUNT(*) FROM type_pkgs '.
+# ' WHERE typenum = '. $cust_main->agent->typenum.
+# ' AND type_pkgs.pkgpart = part_pkg.pkgpart )'.
+# ' )';
</%init>
--- NEW FILE: tr-select-cust-part_pkg.html ---
%if ( scalar(@pkg_class) > 1 && ! $conf->exists('disable-cust-pkg_class') ) {
<% include('/elements/xmlhttp.html',
'url' => $p.'misc/cust-part_pkg.cgi',
'subs' => [ 'get_part_pkg' ],
)
%>
<SCRIPT TYPE="text/javascript">
function opt(what,value,text) {
var optionName = new Option(text, value, false, false);
var length = what.length;
what.options[length] = optionName;
}
function classnum_changed(what) {
what.form.pkgpart.disabled = 'disabled'; //disable part_pkg dropdown
what.form.submit.disabled = true; //disable the submit button
classnum = what.options[what.selectedIndex].value;
function update_part_pkg(part_pkg) {
// blank the current packages
for ( var i = what.form.pkgpart.length; i>= 0; i-- )
what.form.pkgpart.options[i] = null;
// add the new packages
opt(what.form.pkgpart, '', 'Select package');
var packagesArray = eval('(' + part_pkg + ')' );
for ( var s = 0; s < packagesArray.length; s=s+2 ) {
var packagesLabel = packagesArray[s+1];
opt(what.form.pkgpart, packagesArray[s], packagesLabel);
}
what.form.pkgpart.disabled = ''; //re-enable part_pkg dropdown
}
get_part_pkg( <% $cust_main->custnum %>, classnum, update_part_pkg );
}
</SCRIPT>
<TR>
<TH ALIGN="right">Package Class</TH>
<TD COLSPAN=7>
<% include('/elements/select-cust-pkg_class.html',
'curr_value' => $opt{'classnum'},
'pkg_class' => \@pkg_class,
'onchange' => 'classnum_changed',
)
%>
</TD>
</TR>
%}
<TR>
<TH ALIGN="right">Package</TH>
<TD COLSPAN=7>
<% include('/elements/select-cust-part_pkg.html',
'curr_value' => $opt{'curr_value'}, #$pkgpart
'classnum' => $opt{'classnum'},
'cust_main' => $opt{'cust_main'}, #$cust_main
'onchange' => 'enable_order_pkg',
)
%>
</TD>
</TR>
<%init>
my $conf = new FS::Conf;
my %opt = @_;
my $pre_label = $opt{'pre_label'} || '';
$pre_label .= ' ' if length($pre_label) && $pre_label =~ /\S$/;
my $cust_main = $opt{'cust_main'}
or die "cust_main not specified";
#my @pkg_class = sort { $a->classname cmp $b->classname }
# qsearch( 'pkg_class', { 'disabled' => '' } );
#"normal" part_pkg agent virtualization (agentnum or type)
my @part_pkg = qsearch({
'select' => 'DISTINCT classnum',
'table' => 'part_pkg',
'hashref' => { 'disabled' => '' },
'extra_sql' =>
' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql( 'null'=>1 ).
' AND '. FS::part_pkg->agent_pkgs_sql( $opt{'cust_main'}->agent ),
});
my @pkg_class =
sort { $a->classname cmp $b->classname } #should get a sort order in config
map { $_->pkg_class || new FS::pkg_class { 'classnum' => '',
'classname' => '(none)' }
}
@part_pkg;
</%init>
- Previous message: [freeside-commits] freeside/httemplate/misc order_pkg.html, 1.7, 1.8 change_pkg.cgi, 1.10, 1.11 cust-part_pkg.cgi, NONE, 1.1
- Next message: [freeside-commits] freeside/FS/FS Conf.pm, 1.271, 1.272 part_pkg.pm, 1.88, 1.89
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the freeside-commits
mailing list