[freeside-commits] freeside/httemplate/misc order_pkg.html, 1.5, 1.6 location.cgi, NONE, 1.1
Ivan,,,
ivan at wavetail.420.am
Thu Jan 8 20:06:28 PST 2009
- Previous message: [freeside-commits] freeside/httemplate/elements location.html, NONE, 1.1 tr-select-part_referral.html, 1.4, 1.5 select-state.html, 1.2, 1.3 select-county.html, 1.1, 1.2 select-country.html, 1.1, 1.2
- Next message: [freeside-commits] freeside/httemplate/view/cust_main/packages location.html, 1.1, 1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/cvsroot/freeside/httemplate/misc
In directory wavetail.420.am:/tmp/cvs-serv25024/httemplate/misc
Modified Files:
order_pkg.html
Added Files:
location.cgi
Log Message:
pick/enter a location when ordering a package, RT#4499
--- NEW FILE: location.cgi ---
<% objToJson(\%hash) %>
<%init>
my $locationnum = $cgi->param('arg');
my $cust_location = qsearchs({
'table' => 'cust_location',
'hashref' => { 'locationnum' => $locationnum },
'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
});
my %hash = ();
%hash = map { $_ => $cust_location->$_() }
qw( address1 address2 city county state zip country )
if $cust_location;
</%init>
Index: order_pkg.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/misc/order_pkg.html,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- order_pkg.html 29 Mar 2008 08:32:17 -0000 1.5
+++ order_pkg.html 9 Jan 2009 04:06:25 -0000 1.6
@@ -1,13 +1,79 @@
<% include('/elements/header-popup.html', 'Order new package' ) %>
+<% include('/elements/xmlhttp.html',
+ 'url' => $p.'misc/location.cgi',
+ 'subs' => [ 'get_location' ],
+ )
+%>
+
<SCRIPT TYPE="text/javascript">
-function enable_order_pkg () {
- if ( document.OrderPkgForm.pkgpart.selectedIndex > 0 ) {
- document.OrderPkgForm.submit.disabled = false;
- } else {
- document.OrderPkgForm.submit.disabled = true;
+
+ function locationnum_changed(what) {
+ var locationnum = what.options[what.selectedIndex].value;
+ if ( locationnum == -1 ) {
+
+% for (@location_fields) {
+ what.form.<%$_%>.disabled = false;
+ what.form.<%$_%>.style.backgroundColor = '#ffffff';
+% }
+
+ what.form.address1.value = '';
+ what.form.address2.value = '';
+ what.form.city.value = '';
+ what.form.zip.value = '';
+ changeSelect(what.form.country, <% $countrydefault |js_string %>);
+%#shouldn't we sleep/wait here until the state dropdown is updated?
+%#(is it even triggered???)
+ changeSelect(what.form.state, <% $statedefault |js_string %>);
+ what.form.county.selectedIndex = 0;
+
+ } else {
+
+ if ( locationnum == 0 ) {
+ what.form.address1.value = <% $cust_main->address1 |js_string %>;
+ what.form.address2.value = <% $cust_main->address2 |js_string %>;
+ what.form.city.value = <% $cust_main->city |js_string %>;
+ what.form.zip.value = <% $cust_main->zip |js_string %>;
+ changeSelect(what.form.country, <% $cust_main->country | js_string %> );
+%#shouldn't we sleep/wait here until the state dropdown is updated?
+%#(is it even triggered???)
+ changeSelect(what.form.state, <% $cust_main->state | js_string %> );
+%#shouldn't we sleep/wait here until the county dropdown is updated?
+%#(is it even triggered???)
+ changeSelect(what.form.county, <% $cust_main->county | js_string %> );
+ } else {
+ get_location( locationnum, update_location );
+ }
+
+%#sleep/wait until dropdowns are updated?
+% for (@location_fields) {
+ what.form.<%$_%>.disabled = true;
+ what.form.<%$_%>.style.backgroundColor = '#dddddd';
+% }
+
+ }
}
-}
+
+ function changeSelect(what, value) {
+ for ( var i=0; i<what.length; i++) {
+ if ( what.options[i].value == value ) {
+ what.selectedIndex = i;
+ }
+ }
+ }
+
+ function update_location( hash ) {
+ alert(hash);
+ }
+
+ function enable_order_pkg () {
+ if ( document.OrderPkgForm.pkgpart.selectedIndex > 0 ) {
+ document.OrderPkgForm.submit.disabled = false;
+ } else {
+ document.OrderPkgForm.submit.disabled = true;
+ }
+ }
+
</SCRIPT>
<% include('/elements/error.html') %>
@@ -19,7 +85,7 @@
<% ntable("#cccccc", 2) %>
<TR>
<TH ALIGN="right">Package</TH>
- <TD>
+ <TD COLSPAN=7>
<% include('/elements/select-cust-part_pkg.html',
'curr_value' => $pkgpart,
'cust_main' => $cust_main,
@@ -34,10 +100,36 @@
'curr_value' => scalar( $cgi->param('refnum') ), #get rid of empty_label first# || $cust_main->refnum,
'disable_empty' => 1,
'multiple' => $conf->exists('pkg_referral-multiple'),
+ 'colspan' => 7,
)
%>
% }
+<TR>
+ <TH ALIGN="right">Service location</TH>
+ <TD COLSPAN=7>
+ <SELECT NAME="locationnum" onChange="locationnum_changed(this);">
+ <OPTION VALUE="">(default service address)
+% foreach my $loc ( $cust_main->cust_location ) {
+ <OPTION VALUE="<% $loc->locationnum %>"
+ <% $locationnum == $loc->locationnum ? 'SELECTED' : '' %>
+ ><% $loc->line |h %>
+% }
+ <OPTION VALUE="-1"
+ <% $locationnum == -1 ? 'SELECTED' : '' %>
+ >Add new location
+ </SELECT>
+ </TD>
+</TR>
+
+<% include('/elements/location.html',
+ 'object' => $cust_location,
+ #'onchange' ? probably not
+ 'disabled' => ( $locationnum == -1 ? '' : 'DISABLED' ),
+ 'no_asterisks' => 1,
+ )
+%>
+
</TABLE>
<BR>
@@ -46,14 +138,22 @@
</FORM>
</BODY>
</HTML>
+<%once>
+
+my @location_fields = qw( address1 address2 city county state zip country );
+
+</%once>
<%init>
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Order customer package');
my $conf = new FS::Conf;
+my $countrydefault = $conf->config('countrydefault') || 'US';
+my $statedefault = $conf->config('statedefault')
+ || ($countrydefault eq 'US' ? 'CA' : '');
-$cgi->param('custnum') =~ /^(\d+)$/;
+$cgi->param('custnum') =~ /^(\d+)$/ or die "no custnum";
my $custnum = $1;
my $cust_main = qsearchs({
'table' => 'cust_main',
@@ -63,4 +163,19 @@
my $pkgpart = scalar($cgi->param('pkgpart'));
+$cgi->param('locationnum') =~ /^(\d*)$/ or die "illegal locationnum";
+my $locationnum = $1;
+my $cust_location;
+if ( $locationnum ) {
+ $cust_location = qsearchs('cust_location', { 'locationnum' => $locationnum } )
+ or die "unknown locationnum";
+} else {
+ $cust_location = new FS::cust_location;
+ if ( $cgi->param('error') && $locationnum == -1 ) {
+ $cust_location->$_( $cgi->param($_) ) foreach @location_fields;
+ } else {
+ $cust_location->$_( $cust_main->$_() ) foreach @location_fields;
+ }
+}
+
</%init>
- Previous message: [freeside-commits] freeside/httemplate/elements location.html, NONE, 1.1 tr-select-part_referral.html, 1.4, 1.5 select-state.html, 1.2, 1.3 select-county.html, 1.1, 1.2 select-country.html, 1.1, 1.2
- Next message: [freeside-commits] freeside/httemplate/view/cust_main/packages location.html, 1.1, 1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the freeside-commits
mailing list