From: mark Date: Tue, 25 Jan 2011 01:52:20 +0000 (+0000) Subject: missing files for new locations UI, RT#10766 X-Git-Tag: freeside_2_1_2~107 X-Git-Url: http://git.freeside.biz/gitweb/?a=commitdiff_plain;h=0f76306da04936d1f425df857d4ef1ae1d6a8651;p=freeside.git missing files for new locations UI, RT#10766 --- diff --git a/httemplate/view/cust_main/locations.html b/httemplate/view/cust_main/locations.html new file mode 100755 index 000000000..ea6216ea9 --- /dev/null +++ b/httemplate/view/cust_main/locations.html @@ -0,0 +1,87 @@ + +% foreach my $locationnum (@sorted) { +% my $packages = $packages_in{$locationnum}; +% my $loc = $locations{$locationnum}; +% next if $loc->disabled and scalar(@$packages) == 0; +<% include('/elements/table-grid.html') %> + + +% if (! $locationnum) { +Default service location: +% } +% elsif ( $loc->disabled ) { + +% } +<% $loc->location_label %> + +% if ( $locationnum and !$loc->disabled ) { +<% edit_location_link($locationnum) %> +% } +% if ( $locationnum and !$loc->disabled and !$active{$locationnum} ) { + <% disable_location_link($locationnum) %> +% } + +% if (@$packages) { +<% include('packages/section.html', 'packages' => $packages ) %> +% } +
+% } #foreach $locationnum +<%init> +my %opt = @_; +my $cust_main = $opt{'cust_main'}; +my $all_packages = $opt{'packages'}; + +my %locations = map { $_->locationnum => $_ } qsearch({ + 'table' => 'cust_location', + 'hashref' => { 'custnum' => $cust_main->custnum }, + 'order_by' => 'ORDER BY country, state, city, address1, locationnum', + }); +my @sections = keys %locations; +$locations{''} = $cust_main; +my %packages_in = map { $_ => [] } ('', @sections); + +my %active = (); # groups with non-canceled packages +foreach my $cust_pkg ( @$all_packages ) { + my $key = $cust_pkg->locationnum; + push @{ $packages_in{$key} }, $cust_pkg; + $active{$key} = 1 if !$cust_pkg->getfield('cancel'); +} + +my @sorted = ( + '', + grep ( { $active{$_} } @sections), + grep ( { !$active{$_} } @sections), +); + +sub edit_location_link { + my $locationnum = shift; + include( '/elements/popup_link.html', + 'action' => $p. "edit/cust_location.cgi?locationnum=$locationnum", + 'label' => '(Edit location)', + 'actionlabel' => 'Edit', + ); +} + +sub disable_location_link { + my $locationnum = shift; + include( '/elements/popup_link.html', + 'action' => $p. "misc/disable-cust_location.cgi?locationnum=$locationnum", + 'label' => '(Disable location)', + 'actionlabel' => 'Disable', + ); +} + + + diff --git a/httemplate/view/cust_main/packages/package.html b/httemplate/view/cust_main/packages/package.html index 3b58f9ec0..8cae5fdba 100644 --- a/httemplate/view/cust_main/packages/package.html +++ b/httemplate/view/cust_main/packages/package.html @@ -168,8 +168,16 @@ % } +% if ( $curuser->access_right('Change customer package') and +% !$cust_pkg->get('cancel') and +% !$opt{'show_location'}) { + + + ( <% pkg_change_location_link($cust_pkg) %> ) + + +% } % } - @@ -184,6 +192,10 @@ my $part_pkg = $opt{'part_pkg'}; my $curuser = $FS::CurrentUser::CurrentUser; +my $countrydefault = $opt{'countrydefault'} || 'US'; +my $statedefault = $opt{'statedefault'} + || ($countrydefault eq 'US' ? 'CA' : ''); + #subroutines #false laziness w/status.html @@ -204,6 +216,19 @@ sub pkg_change_link { ); } +sub pkg_change_location_link { + my $cust_pkg = shift; + my $pkgpart = $cust_pkg->pkgpart; + include( '/elements/popup_link-cust_pkg.html', + 'action' => $p. "misc/change_pkg.cgi?locationnum=-1;pkgpart=$pkgpart;". + "address1=;address2=;city=;county=;state=$statedefault;". + "zip=;country=$countrydefault", + 'label' => 'Change location', + 'actionlabel' => 'Change', + 'cust_pkg' => $cust_pkg, + ); +} + sub pkg_dates_link { pkg_link('edit/REAL_cust_pkg', 'Edit dates', @_ ); } sub pkg_discount_link {