summaryrefslogtreecommitdiff
path: root/httemplate/misc
diff options
context:
space:
mode:
authorivan <ivan>2009-03-28 22:59:36 +0000
committerivan <ivan>2009-03-28 22:59:36 +0000
commite3c3d86b7091d806af42e40475a28ea8afb5865c (patch)
tree8c3f95b1f917e84468adeed6b7cf385fdbf68658 /httemplate/misc
parent3868d5117cbfeb2d1f75ffe3d5dc96aa63f1e809 (diff)
package selector, split by package class, RT#5077
Diffstat (limited to 'httemplate/misc')
-rwxr-xr-xhttemplate/misc/change_pkg.cgi22
-rw-r--r--httemplate/misc/cust-part_pkg.cgi29
-rw-r--r--httemplate/misc/order_pkg.html18
3 files changed, 45 insertions, 24 deletions
diff --git a/httemplate/misc/change_pkg.cgi b/httemplate/misc/change_pkg.cgi
index c4dfca200..16b707121 100755
--- a/httemplate/misc/change_pkg.cgi
+++ b/httemplate/misc/change_pkg.cgi
@@ -13,19 +13,15 @@
<% $curuser->option('show_pkgnum') ? $cust_pkg->pkgnum.': ' : '' %><B><% $part_pkg->pkg |h %></B> - <% $part_pkg->comment |h %>
</TD>
</TR>
-
- <TR>
- <TH ALIGN="right">New package</TH>
- <TD COLSPAN=7>
- <% include('/elements/select-cust-part_pkg.html',
- 'cust_main' => $cust_main,
- 'element_name' => 'pkgpart',
- #'extra_sql' => ' AND pkgpart != '. $cust_pkg->pkgpart,
- 'curr_value' => scalar($cgi->param('pkgpart')),
- )
- %>
- </TD>
- </TR>
+
+ <% include('/elements/tr-select-cust-part_pkg.html',
+ 'pre_label' => 'New',
+ 'curr_value' => scalar($cgi->param('pkgpart')),
+ 'classnum' => $part_pkg->classnum,
+ 'cust_main' => $cust_main,
+ #'extra_sql' => ' AND pkgpart != '. $cust_pkg->pkgpart,
+ )
+ %>
<% include('/elements/tr-select-cust_location.html',
'cgi' => $cgi,
diff --git a/httemplate/misc/cust-part_pkg.cgi b/httemplate/misc/cust-part_pkg.cgi
new file mode 100644
index 000000000..a249f033f
--- /dev/null
+++ b/httemplate/misc/cust-part_pkg.cgi
@@ -0,0 +1,29 @@
+<% objToJson( \@return ) %>
+<%init>
+
+my( $custnum, $classnum ) = $cgi->param('arg');
+
+#XXX i guess i should be agent-virtualized. cause "packages a customer can
+#order" is such a huge deal
+my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } );
+
+my %hash = ( 'disabled' => '' );
+if ( $classnum > 0 ) {
+ $hash{'classnum'} = $classnum;
+} elsif ( $classnum eq '' || $classnum == 0 ) {
+ $hash{'classnum'} = '';
+} #else -1, all classes, so don't set classnum
+
+my @part_pkg = qsearch({
+ 'table' => 'part_pkg',
+ 'hashref' => \%hash,
+ 'extra_sql' =>
+ ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql( 'null'=>1 ).
+ ' AND '. FS::part_pkg->agent_pkgs_sql( $cust_main->agent ),
+});
+
+my @return = map { $_->pkgpart => $_->pkg_comment }
+ sort { $a->pkg_comment cmp $b->pkg_comment }
+ @part_pkg;
+
+</%init>
diff --git a/httemplate/misc/order_pkg.html b/httemplate/misc/order_pkg.html
index 2c8335154..9caa57a69 100644
--- a/httemplate/misc/order_pkg.html
+++ b/httemplate/misc/order_pkg.html
@@ -19,17 +19,13 @@
<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $cust_main->custnum %>">
<% ntable("#cccccc", 2) %>
-<TR>
- <TH ALIGN="right">Package</TH>
- <TD COLSPAN=7>
- <% include('/elements/select-cust-part_pkg.html',
- 'curr_value' => $pkgpart,
- 'cust_main' => $cust_main,
- 'onchange' => 'enable_order_pkg',
- )
- %>
- </TD>
-</TR>
+<% include('/elements/tr-select-cust-part_pkg.html',
+ 'curr_value' => $pkgpart,
+ 'classnum' => -1,
+ 'cust_main' => $cust_main,
+ 'onchange' => 'enable_order_pkg',
+ )
+%>
% if ( $conf->exists('pkg_referral') ) {
<% include('/elements/tr-select-part_referral.html',