diff options
| author | ivan <ivan> | 2007-08-02 23:01:02 +0000 | 
|---|---|---|
| committer | ivan <ivan> | 2007-08-02 23:01:02 +0000 | 
| commit | e498c4a6c0dd05b890e71b04465f208cadfa8097 (patch) | |
| tree | 913f06ba43453fcd2a051b9b35c7d6c1738c5789 | |
| parent | 6081d4d551a6814442ef70cb65cd1e3262a335ab (diff) | |
fix slowness on change package and also make it into a popup
| -rw-r--r-- | httemplate/elements/select-cust-part_pkg.html | 56 | 
1 files changed, 56 insertions, 0 deletions
diff --git a/httemplate/elements/select-cust-part_pkg.html b/httemplate/elements/select-cust-part_pkg.html new file mode 100644 index 000000000..8b446b95d --- /dev/null +++ b/httemplate/elements/select-cust-part_pkg.html @@ -0,0 +1,56 @@ +<%doc> + +Example: + +  include( '/elements/select-cust-part_pkg.html', + +    #required +    'cust_main'  => $cust_main, #or 'custnum' ?  +              +    #strongly recommended (you want your forms to be "sticky" on errors, right?) +    'curr_value' => 'current_value', +   +    #opt +    'part_pkg'   => \@records, + +    #select-table.html options +  ) + +</%doc> + +<% include( '/elements/select-table.html', +              'table'          => 'part_pkg', +              'name_col'       => 'pkg', +              'empty_label'    => 'Select package', +              'label_callback' => sub { $_[0]->pkgpart. ': '. +                                        $_[0]->pkg.     ' - '. +                                        $_[0]->comment; +                                      }, +              %opt, +          ) +%> +<%init> + +my( %opt ) = @_; + +my $cust_main = $opt{'cust_main'} +  or die "cust_main not specified"; + +$opt{'records'} = delete $opt{'part_pkg'} +  if $opt{'part_pkg'}; + +my $extra_sql = $opt{'extra_sql'}. +  ' AND 0 < ( SELECT COUNT(*) FROM type_pkgs '. +  '             WHERE typenum = '. $cust_main->agent->typenum. +  '             AND type_pkgs.pkgpart = part_pkg.pkgpart )'; + +$opt{'records'} ||= [ qsearch({  +                                'table'     => 'part_pkg', +                                'hashref'   => { 'disabled' => '', }, +                                'extra_sql' => "$extra_sql ORDER BY pkg", +                                #'extra_sql' => $extra_sql, +                                #'order_by'  => 'ORDER BY pkg', +                             }) +                    ]; + +</%init>  | 
