diff options
Diffstat (limited to 'httemplate')
| -rw-r--r-- | httemplate/elements/search-cust_main.html | 5 | ||||
| -rwxr-xr-x | httemplate/misc/cust_main-merge.html | 40 | ||||
| -rw-r--r-- | httemplate/misc/merge_cust.html | 72 | ||||
| -rwxr-xr-x | httemplate/view/cust_main.cgi | 16 |
4 files changed, 132 insertions, 1 deletions
diff --git a/httemplate/elements/search-cust_main.html b/httemplate/elements/search-cust_main.html index 317922d3c..e8c645eca 100644 --- a/httemplate/elements/search-cust_main.html +++ b/httemplate/elements/search-cust_main.html @@ -11,7 +11,7 @@ Example: ); </%doc> -<INPUT TYPE="hidden" NAME="<% $field %>" VALUE="<% $value %>"> +<INPUT TYPE="hidden" NAME="<% $field %>" ID="<% $field %>" VALUE="<% $value %>"> <!-- some false laziness w/ misc/batch-cust_pay.html, though not as bad as i'd thought at first... --> @@ -60,6 +60,9 @@ Example: function smart_<% $field %>_search(what) { + if ( <% $field %>_search_active ) + return; + var customer = what.value; if ( customer == 'searching...' || customer == '' diff --git a/httemplate/misc/cust_main-merge.html b/httemplate/misc/cust_main-merge.html new file mode 100755 index 000000000..4decbef7a --- /dev/null +++ b/httemplate/misc/cust_main-merge.html @@ -0,0 +1,40 @@ +% if ( $error ) { +% $cgi->param('error', $error); +<% $cgi->redirect(popurl(1). "merge_cust.html?". $cgi->query_string ) %> +% } else { +<% include('/elements/header-popup.html', "Customer merged") %> + <SCRIPT TYPE="text/javascript"> + window.top.location.href = '<% $p %>view/cust_main.cgi?<% $new_custnum %>'; +%# parent.nd(1) ? + </SCRIPT> + </BODY> +</HTML> +% } +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Merge customer'); + +my $error = ''; + +$cgi->param('custnum') =~ /^(\d+)$/ or die "illegal custnum"; +my $custnum = $1; + +my $new_custnum; +if ( $cgi->param('new_custnum') =~ /^(\d+)$/ ) { + $new_custnum = $1; + + my $cust_main = qsearchs( { + 'table' => 'cust_main', + 'hashref' => { 'custnum' => $custnum }, + 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql, + } ); + die "No customer # $custnum" unless $cust_main; + + $error = $cust_main->merge($new_custnum); + +} else { + $error = 'Select a customer to merge into'; +} + +</%init> diff --git a/httemplate/misc/merge_cust.html b/httemplate/misc/merge_cust.html new file mode 100644 index 000000000..ad075be2f --- /dev/null +++ b/httemplate/misc/merge_cust.html @@ -0,0 +1,72 @@ +<% include('/elements/header-popup.html', 'Merge customer' ) %> + +<% include('/elements/error.html') %> + +<FORM NAME="cust_merge_popup" ID="cust_merge_popup" ACTION="<% popurl(1) %>cust_main-merge.html" METHOD=POST onSubmit="submit_merge(); return false;"> + +<SCRIPT TYPE="text/javascript"> + +var submit_interval_id; +function submit_merge() { + document.getElementById('confirm_merge_cust_button').disabled = 'true'; + smart_new_custnum_search(document.getElementById('new_custnum_search')); + submit_interval_id = setInterval( do_submit_merge, 100); +} + +function do_submit_merge() { + + if ( new_custnum_search_active ) + return; + + document.getElementById('confirm_merge_cust_button').disabled = ''; + + clearInterval(submit_interval_id); + + if ( document.cust_merge_popup.new_custnum.value != '' ) { + document.cust_merge_popup.submit(); + } + +} + +</SCRIPT> + +</SCRIPT> + +<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>"> + +<TABLE BORDER="0" CELLSPACING="2" STYLE="margin-left:auto; margin-right:auto"> + <% include('/elements/tr-search-cust_main.html', + 'label' => 'Merge into: ', + 'field' => 'new_custnum', + 'find_button' => 1, + 'curr_value' => scalar($cgi->param('new_custnum')), + ) + %> +</TABLE> + +<P ALIGN="CENTER"> +%#have merge button start out disabled and enable after you select a target cust +<INPUT TYPE="submit" NAME="confirm_merge_cust_button" ID="confirm_merge_cust_button" VALUE="Merge customer"> <INPUT TYPE="BUTTON" VALUE="Don't merge" onClick="parent.cClick();"> + +</FORM> +</BODY> +</HTML> + +<%init> + +$cgi->param('custnum') =~ /^(\d+)$/ or die 'illegal custnum'; +my $custnum = $1; + +my $curuser = $FS::CurrentUser::CurrentUser; + +die "access denied" unless $curuser->access_right('Merge customer'); + +my $cust_main = qsearchs( { + 'table' => 'cust_main', + 'hashref' => { 'custnum' => $custnum }, + 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql, +} ); +die "No customer # $custnum" unless $cust_main; + +</%init> + diff --git a/httemplate/view/cust_main.cgi b/httemplate/view/cust_main.cgi index b4a6170c5..0f9c1e250 100755 --- a/httemplate/view/cust_main.cgi +++ b/httemplate/view/cust_main.cgi @@ -64,6 +64,22 @@ function areyousure(href, message) { % } +% if ( $curuser->access_right('Merge customer') ) { + + <% include( '/elements/popup_link-cust_main.html', + { 'action' => $p. 'misc/merge_cust.html', + 'label' => 'Merge this customer', + 'actionlabel' => 'Merge customer', + #'color' => '#ff0000', + 'cust_main' => $cust_main, + 'width' => 480, + 'height' => 192, + } + ) + %> | + +% } + % if ( $conf->exists('deletecustomers') % && $curuser->access_right('Delete customer') % ) { |
