[freeside-commits] branch master updated. 6c063e24b90cd374623e2841045fe4c61bed8143

Mark Wells mark at 420.am
Thu Feb 28 23:32:59 PST 2013


The branch, master has been updated
       via  6c063e24b90cd374623e2841045fe4c61bed8143 (commit)
       via  71cfb409fca5c4f8cfb639a0f022de8c640b7775 (commit)
      from  2bdfa5c7730b31c51956d190aa0df2728181ab9c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 6c063e24b90cd374623e2841045fe4c61bed8143
Author: Mark Wells <mark at freeside.biz>
Date:   Thu Feb 28 23:32:07 2013 -0800

    enforce agent-ship_address in backend interface, #21327

diff --git a/httemplate/edit/cust_main/top_misc.html b/httemplate/edit/cust_main/top_misc.html
index cfed8e4..f2f584f 100644
--- a/httemplate/edit/cust_main/top_misc.html
+++ b/httemplate/edit/cust_main/top_misc.html
@@ -32,6 +32,35 @@
       document.getElementById('contacts_div').style.display = 'none';
     }
   }
+
+  var ship_locked_agents = <% encode_json(\%ship_locked_agents) %>;
+  var ship_fields = ['address1', 'city', 'state', 'zip', 'country', 
+    'latitude', 'longitude', 'district'];
+  function agent_changed(what) {
+    var agentnum = what.value;
+    var f = what.form;
+    if ( ship_locked_agents[agentnum] ) {
+      for(var x in ship_locked_agents[agentnum]) {
+        f['ship_'+x].value = ship_locked_agents[agentnum][x];
+        f['ship_'+x].disabled = true;
+      }
+      f['same'].checked = false;
+      f['same'].disabled = true;
+    } else {
+      for(var i=0; i<ship_fields.length; i++) {
+        x = ship_fields[i];
+        f['ship_'+x].value = '';
+        f['ship_'+x].disabled = false;
+      }
+      f['same'].checked = true;
+      f['same'].disabled = false;
+    }
+    samechanged(f['same']);
+  }
+  window.onload = function() {
+    agent_changed(document.getElementById('agentnum'));
+  }
+ 
 </SCRIPT>
 
 % foreach my $field ($cust_main->virtual_fields) {
@@ -51,12 +80,13 @@
 %   $cust_main->agentnum($agentnum);
 
     <INPUT TYPE="hidden" NAME="lock_agentnum" VALUE="<% $agentnum %>">
-    <INPUT TYPE="hidden" NAME="agentnum"      VALUE="<% $agentnum %>">
+    <INPUT TYPE="hidden" NAME="agentnum"      ID="agentnum" 
+      VALUE="<% $agentnum %>">
     <TR>
       <TD ALIGN="right"><% mt('Agent') |h %></TD>
       <TD CLASS="fsdisabled"><% $cust_main->agent->agent |h %></TD>
     </TR>
- 
+
 % } else {
 
   <& /elements/tr-select-agent.html, 
@@ -65,6 +95,7 @@
                 'empty_label'   => emt('Select agent'),
                 'disable_empty' => ( $cust_main->agentnum ? 1 : 0 ),
                 'viewall_right' => emt('None'), 
+                'onchange'      => 'agent_changed(this)',
   &>
 
 % }
@@ -201,4 +232,17 @@ my $curuser = $FS::CurrentUser::CurrentUser;
 
 my $r = qq!<font color="#ff0000">*</font> !;
 
+# which agents lock the service address, if any
+my %ship_locked_agents;
+foreach (qsearch('agent',{})) {
+  my $agentnum = $_->agentnum;
+  next unless $conf->exists('agent-ship_address', $_->agentnum);
+  my $cust_main = $_->agent_cust_main or next;
+  my $agent_ship_location = $cust_main->ship_location;
+  $ship_locked_agents{$agentnum} = +{
+    map { $_ => $agent_ship_location->$_ }
+    qw(address1 city state zip country latitude longitude district)
+  };
+}
+
 </%init>
diff --git a/httemplate/edit/process/cust_main.cgi b/httemplate/edit/process/cust_main.cgi
index 584462c..054973f 100755
--- a/httemplate/edit/process/cust_main.cgi
+++ b/httemplate/edit/process/cust_main.cgi
@@ -62,6 +62,18 @@ $cgi->param('invoicing_list', join(',', @invoicing_list) );
 $cgi->param('duplicate_of_custnum') =~ /^(\d+)$/;
 my $duplicate_of = $1;
 
+# if this is enabled, enforce it
+if ( $conf->exists('agent-ship_address', $cgi->param('agentnum')) ) {
+  my $agent = FS::agent->by_key($cgi->param('agentnum'));
+  my $agent_cust_main = $agent->agent_cust_main;
+  if ( $agent_cust_main ) {
+    my $agent_location = $agent_cust_main->ship_location;
+    foreach (qw(address1 city state zip country latitude longitude district)) {
+      $cgi->param("ship_$_", $agent_location->get($_));
+    }
+  }
+}
+
 my %locations;
 for my $pre (qw(bill ship)) {
 
diff --git a/httemplate/elements/location.html b/httemplate/elements/location.html
index 873fe16..b142aa6 100644
--- a/httemplate/elements/location.html
+++ b/httemplate/elements/location.html
@@ -200,7 +200,7 @@ Example:
 </TR>
 % } else {
 %   foreach (qw(latitude longitude)) {
-<INPUT TYPE="hidden" NAME="<% $_ %>" VALUE="<% $object->get($_) |h%>">
+<INPUT TYPE="hidden" NAME="<% $_ %>" ID="<% $_ %>" VALUE="<% $object->get($_) |h%>">
 %   }
 % }
 <INPUT TYPE="hidden" NAME="<%$pre%>coord_auto" VALUE="<% $object->coord_auto %>">
@@ -226,12 +226,13 @@ Example:
     <TD COLSPAN=8>
       <INPUT TYPE="text" SIZE=15
              NAME="<%$pre%>district" 
+             ID="<%$pre%>district"
              VALUE="<% $object->district |h %>">
     <% '(automatic)' %>
     </TD>
   </TR>
 %   } else {
-    <INPUT TYPE="hidden" NAME="<%$pre%>district" VALUE="<% $object->district %>">
+    <INPUT TYPE="hidden" ID="<%$pre%>" NAME="<%$pre%>district" VALUE="<% $object->district %>">
 %   }
 % }
 

commit 71cfb409fca5c4f8cfb639a0f022de8c640b7775
Author: Mark Wells <mark at freeside.biz>
Date:   Thu Feb 28 20:31:12 2013 -0800

    import an incredibly useful debugging tool from 2.3

diff --git a/FS/FS/Misc.pm b/FS/FS/Misc.pm
index 5e89abc..de9fb52 100644
--- a/FS/FS/Misc.pm
+++ b/FS/FS/Misc.pm
@@ -699,7 +699,8 @@ sub generate_ps {
   open(POSTSCRIPT, "<$file.ps")
     or die "can't open $file.ps: $! (error in LaTeX template?)\n";
 
-  unlink("$file.dvi", "$file.log", "$file.aux", "$file.ps", "$file.tex");
+  unlink("$file.dvi", "$file.log", "$file.aux", "$file.ps", "$file.tex")
+    unless $FS::CurrentUser::CurrentUser->option('save_tmp_typesetting');
 
   my $ps = '';
 
@@ -757,7 +758,8 @@ sub generate_pdf {
   open(PDF, "<$file.pdf")
     or die "can't open $file.pdf: $! (error in LaTeX template?)\n";
 
-  unlink("$file.dvi", "$file.log", "$file.aux", "$file.pdf", "$file.tex");
+  unlink("$file.dvi", "$file.log", "$file.aux", "$file.pdf", "$file.tex")
+    unless $FS::CurrentUser::CurrentUser->option('save_tmp_typesetting');
 
   my $pdf = '';
   while (<PDF>) {
diff --git a/httemplate/pref/pref-process.html b/httemplate/pref/pref-process.html
index c4fef03..84f0832 100644
--- a/httemplate/pref/pref-process.html
+++ b/httemplate/pref/pref-process.html
@@ -57,7 +57,7 @@ unless ( $error ) { # if ($access_user) {
                       vonage-fromnumber vonage-username vonage-password
                       cust_pkg-display_times
                       show_pkgnum show_confitem_counts export_getsettings
-                      show_db_profile save_db_profile
+                      show_db_profile save_db_profile save_tmp_typesetting
                       height width availHeight availWidth colorDepth
                     );
 
diff --git a/httemplate/pref/pref.html b/httemplate/pref/pref.html
index 1e9671d..9537fed 100644
--- a/httemplate/pref/pref.html
+++ b/httemplate/pref/pref.html
@@ -157,6 +157,10 @@ Development
     <TH>Save database profiling logs (when available): </TH>
     <TD><INPUT TYPE="checkbox" NAME="save_db_profile" VALUE="1" <% $curuser->option('save_db_profile') ? 'CHECKED' : '' %>></TD>
   </TR>
+  <TR>
+    <TH>Save temporary invoice typesetting files: </TH>
+    <TD><INPUT TYPE="checkbox" NAME="save_tmp_typesetting" VALUE="1" <% $curuser->option('save_tmp_typesetting') ? 'CHECKED' : '' %>></TD>
+  </TR>
 
 </TABLE>
 <BR>

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Misc.pm                           |    6 ++-
 httemplate/edit/cust_main/top_misc.html |   48 +++++++++++++++++++++++++++++-
 httemplate/edit/process/cust_main.cgi   |   12 ++++++++
 httemplate/elements/location.html       |    5 ++-
 httemplate/pref/pref-process.html       |    2 +-
 httemplate/pref/pref.html               |    4 ++
 6 files changed, 70 insertions(+), 7 deletions(-)




More information about the freeside-commits mailing list