summaryrefslogtreecommitdiff
path: root/httemplate/elements
diff options
context:
space:
mode:
authorivan <ivan>2009-02-08 02:05:48 +0000
committerivan <ivan>2009-02-08 02:05:48 +0000
commit24533a22a23e211888fcc36a5177c0def5c77de3 (patch)
tree09887e29cf74dc4e50ab03e23514acc0d69e59b2 /httemplate/elements
parent8b72ad2a4d67f46e4bda36179e992d82d069689f (diff)
further work on agents editing own packages: allow them to see (but not edit) global packages for their type, RT#1331
Diffstat (limited to 'httemplate/elements')
-rw-r--r--httemplate/elements/select-agent_types.html2
-rw-r--r--httemplate/elements/select-cust-part_pkg.html8
-rw-r--r--httemplate/elements/select-part_pkg.html18
-rw-r--r--httemplate/elements/select-table.html4
-rw-r--r--httemplate/elements/tr-select-agent_types.html2
5 files changed, 28 insertions, 6 deletions
diff --git a/httemplate/elements/select-agent_types.html b/httemplate/elements/select-agent_types.html
index e56fee43c..400b453b3 100644
--- a/httemplate/elements/select-agent_types.html
+++ b/httemplate/elements/select-agent_types.html
@@ -1,5 +1,5 @@
%# if ( $cgi->param('clone') ) { #XXX
-% if ( $opt{'disable'} ) {
+% if ( $opt{'disabled'} ) {
<INPUT TYPE="hidden" NAME="agent_type" VALUE="">
diff --git a/httemplate/elements/select-cust-part_pkg.html b/httemplate/elements/select-cust-part_pkg.html
index 57da5cd84..292662921 100644
--- a/httemplate/elements/select-cust-part_pkg.html
+++ b/httemplate/elements/select-cust-part_pkg.html
@@ -32,8 +32,10 @@ my $cust_main = $opt{'cust_main'}
or die "cust_main not specified";
$opt{'extra_sql'} .=
- ' AND 0 < ( SELECT COUNT(*) FROM type_pkgs '.
- ' WHERE typenum = '. $cust_main->agent->typenum.
- ' AND type_pkgs.pkgpart = part_pkg.pkgpart )';
+ ' 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>
diff --git a/httemplate/elements/select-part_pkg.html b/httemplate/elements/select-part_pkg.html
index a1d5f40f2..cd6d24c28 100644
--- a/httemplate/elements/select-part_pkg.html
+++ b/httemplate/elements/select-part_pkg.html
@@ -17,6 +17,8 @@ Example:
<% include( '/elements/select-table.html',
'table' => 'part_pkg',
+ 'agent_virt' => 1,
+ 'agent_null' => 1,
'name_col' => 'pkg',
'empty_label' => 'Select package', #should this be the default?
'label_callback' => sub { shift->pkg_comment },
@@ -31,4 +33,20 @@ my( %opt ) = @_;
$opt{'records'} = delete $opt{'part_pkg'}
if $opt{'part_pkg'};
+#false laziness w/browse/part_pkg.cgi
+my $agentnums = join(',', $FS::CurrentUser::CurrentUser->agentnums);
+
+$opt{'extra_sql'} .=
+ " AND ( agentnum IS NOT NULL
+ OR 0 < ( SELECT COUNT(*)
+ FROM type_pkgs
+ LEFT JOIN agent_type USING ( typenum )
+ LEFT JOIN agent AS typeagent USING ( typenum )
+ WHERE type_pkgs.pkgpart = part_pkg.pkgpart
+ AND typeagent.agentnum IN ($agentnums)
+ )
+ )
+ ";
+#eofalse
+
</%init>
diff --git a/httemplate/elements/select-table.html b/httemplate/elements/select-table.html
index 32a61e989..4efbcbaf3 100644
--- a/httemplate/elements/select-table.html
+++ b/httemplate/elements/select-table.html
@@ -24,6 +24,7 @@ Example:
'extra_sql' => '',
'agent_virt' => 0, #set true and make sure the result is JOINed to
#something with agentnum (usually cust_main)
+ 'agent_null' => 0, #set true to always show un-agented entries
'agent_null_right' => '', #right to see un-agented entries
#or
'records' => \@records, #instead of search params
@@ -120,7 +121,8 @@ if ( $opt{'agent_virt'} ) {
$extra_sql .=
( $extra_sql =~ /WHERE/i || scalar(keys %$hashref ) ? ' AND ' : ' WHERE ' ).
$FS::CurrentUser::CurrentUser->agentnums_sql(
- 'null_right' => $opt{'agent_null_right'}
+ 'null' => $opt{'agent_null'},
+ 'null_right' => $opt{'agent_null_right'},
);
}
diff --git a/httemplate/elements/tr-select-agent_types.html b/httemplate/elements/tr-select-agent_types.html
index 29ac7f1b4..efbf386a7 100644
--- a/httemplate/elements/tr-select-agent_types.html
+++ b/httemplate/elements/tr-select-agent_types.html
@@ -1,4 +1,4 @@
-% unless ( $opt{'disable'} || scalar(@all_agent_types) == 1 ) {
+% unless ( $opt{'disabled'} || scalar(@all_agent_types) == 1 ) {
<% include('/elements/tr-justtitle.html', value=>'Agent (reseller) types') %>