From 576c6b48428aa95e0fd80db011fe73c0b728c88b Mon Sep 17 00:00:00 2001 From: jeff Date: Fri, 27 Oct 2006 17:01:31 +0000 Subject: [PATCH] editable notes --- FS/FS/AccessRight.pm | 1 + httemplate/edit/cust_main_note.cgi | 20 +++++++++++-- httemplate/edit/process/cust_main_note.cgi | 19 ++++++++++-- httemplate/elements/overlibmws_crossframe.js | 44 ++++++++++++++++++++++++++++ httemplate/view/cust_main/notes.html | 41 +++++++++++++++++++------- 5 files changed, 110 insertions(+), 15 deletions(-) create mode 100644 httemplate/elements/overlibmws_crossframe.js diff --git a/FS/FS/AccessRight.pm b/FS/FS/AccessRight.pm index 64c4f6b38..5370e2281 100644 --- a/FS/FS/AccessRight.pm +++ b/FS/FS/AccessRight.pm @@ -93,6 +93,7 @@ assigned to users and/or groups. 'Complimentary customer', #aka users-allow_comp 'Delete customer', #aka. deletecustomers #Enable customer deletions. Be very careful! Deleting a customer will remove all traces that this customer ever existed! It should probably only be used when auditing a legacy database. Normally, you cancel all of a customers' packages if they cancel service. 'Add customer note', + 'Edit customer note', ### # customer package rights diff --git a/httemplate/edit/cust_main_note.cgi b/httemplate/edit/cust_main_note.cgi index 468ef0051..303895bd8 100755 --- a/httemplate/edit/cust_main_note.cgi +++ b/httemplate/edit/cust_main_note.cgi @@ -1,4 +1,4 @@ -<% include('/elements/header-popup.html', 'Add Customer Note') %> +<% include('/elements/header-popup.html', "$action Customer Note") %> % if ( $cgi->param('error') ) { Error: <% $cgi->param('error') %> @@ -7,6 +7,7 @@
+

@@ -15,23 +16,36 @@

- +">
<%init> -my($custnum, $comment); +my($custnum, $comment, $notenum, $action); $comment = ''; if ( $cgi->param('error') ) { $comment = $cgi->param('comment'); +}elsif ($cgi->param('notenum')) { + $cgi->param('notenum') =~ /^(\d+)$/; + $notenum = $1; + die "illegal query ". $cgi->keywords unless $notenum; + my $note = qsearchs('cust_main_note', { 'notenum' => $notenum }); + die "no such note: ". $notenum unless $note; + $comment = $note->comments; } + +$cgi->param('notenum') =~ /^(\d+)$/; +$notenum = $1; + $cgi->param('custnum') =~ /^(\d+)$/; $custnum = $1; die "illegal query ". $cgi->keywords unless $custnum; +$action = $notenum ? 'Edit' : 'Add'; + diff --git a/httemplate/edit/process/cust_main_note.cgi b/httemplate/edit/process/cust_main_note.cgi index d9251f042..b94d2271c 100755 --- a/httemplate/edit/process/cust_main_note.cgi +++ b/httemplate/edit/process/cust_main_note.cgi @@ -4,18 +4,33 @@ % or die "Illegal custnum: ". $cgi->param('custnum'); %my $custnum = $1; % +%$cgi->param('notenum') =~ /^(\d+)$/ +% or die "Illegal notenum: ". $cgi->param('notenum'); +%my $notenum = $1; +% %my $otaker = $FS::CurrentUser::CurrentUser->name; %$otaker = $FS::CurrentUser::CurrentUser->username % if ($otaker eq "User, Legacy"); % %my $new = new FS::cust_main_note ( { +% notenum => $notenum, % custnum => $custnum, % _date => time, % otaker => $otaker, % comments => $cgi->param('comment'), %} ); % -%my $error = $new->insert; +%my $error; +%if ($notenum){ +% my $old = qsearchs('cust_main_note', { 'notenum' => $notenum }); +% $error = "No such note: $notenum" unless $old; +% unless($error){ +% map { $new->$_($old->$_) } ('_date', 'otaker'); +% $error = $new->replace($old); +% } +%}else{ +% $error = $new->insert; +%} % %if ($error) { % $cgi->param('error', $error); @@ -23,7 +38,7 @@ %} % % -<% header('Note added') %> +<% header('Note ' . ($notenum ? 'updated' : 'added') ) %> diff --git a/httemplate/elements/overlibmws_crossframe.js b/httemplate/elements/overlibmws_crossframe.js new file mode 100644 index 000000000..6b21c42e8 --- /dev/null +++ b/httemplate/elements/overlibmws_crossframe.js @@ -0,0 +1,44 @@ +/* + overlibmws_crossframe.js plug-in module - Copyright Foteos Macrides 2003-2006 + For support of FRAME. + Initial: August 3, 2003 - Last Revised: November 2, 2004 + See the Change History and Command Reference for overlibmws via: + + http://www.macridesweb.com/oltest/ + + Published under an open source license: http://www.macridesweb.com/oltest/license.html +*/ + +OLloaded=0; +OLregCmds('frame'); + +function OLparseCrossframe(pf,i,ar){ +var k=i,v; +if(k0)))&&(((OLns4))|| +((OLie4)&&(v=thisFrame[i].document.all.tags('iframe'))!=null&&v.length==0)|| +((OLns6)&&(v=thisFrame[i].document.getElementsByTagName('iframe'))!=null&&v.length==0))){ +retVal=OLgetFrameRef(thisFrame[i],ofrm);if(retVal=='')continue;} +else if(thisFrame[i]!=ofrm)continue;retVal='['+i+']'+retVal;break;} +return retVal; +} + +function OLoptFRAME(frm){ +o3_frame=OLmkLyr('overDiv',frm)?frm:self;if(o3_frame!=self){ +var l,tFrm=OLgetFrameRef(top.frames,o3_frame),sFrm=OLgetFrameRef(top.frames,ol_frame); +if(sFrm.length==tFrm.length) {l=tFrm.lastIndexOf('[');if(l){ +while(sFrm.substring(0,l)!=tFrm.substring(0,l))l=tFrm.lastIndexOf('[',l-1); +tFrm=tFrm.substr(l);sFrm=sFrm.substr(l);}}var i,k,cnt=0,p='',str=tFrm; +while((k=str.lastIndexOf('['))!= -1){cnt++;str=str.substring(0,k);} +for(i=0;iparam('custnum') =~ /^(\d+)$/ % or die "No customer specified (bad URL)!"; @@ -20,6 +21,11 @@ body { background: #e8e8e8 } + + + + + %#<% include('/elements/table-grid.html') %> @@ -35,12 +41,27 @@ body { background: #e8e8e8 } % $bgcolor = $bgcolor1; % } % +% my $pop = popurl(3); +% my $notenum = $note->notenum; +% my $clickjs = qq!onclick="overlib( OLiframeContent('${pop}edit/! . +% qq!cust_main_note.cgi?custnum=$custnum&! . +% qq!notenum=$notenum', 616, ! . +% qq!386, 'cust_main_note_popup' ), CAPTION, 'Edit customer ! . +% qq!note', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, ! . +% qq!CLOSECLICK, FRAME, top); return false;"!; % +% my ($el, $eel); +% if ($curuser->access_right('Edit customer note') ) { +% $el = qq!!; +% $eel = qq!!; +% }else{ +% $el = $eel = ''; +% } - <% note_datestr($note,$conf,$bgcolor) %> + <% note_datestr($note,$conf,$bgcolor, $el, $eel) %> }. -% qq{}. -% qq{}; -% $format .= qq{}. -% qq{}. -% qq{}. -% qq{} +% my($note, $conf, $bgcolor, $el, $eel) = @_ or return ''; +% my $format=qq{}. +% qq{}. +% qq{}; +% $format .= qq{}. +% qq{}. +% qq{}. +% qq{} % if $conf->exists('cust_main_note-display_times'); % ( my $strip = time2str($format, $note->_date) ) =~ s/ (\d)/$1/g; % $strip; -- 2.11.0
-  <%$note->otaker%>  + <% $el %>  <%$note->otaker%>  <% $eel %>  <%$note->comments%> @@ -58,14 +79,14 @@ body { background: #e8e8e8 } %#subroutines % %sub note_datestr { -% my($note, $conf, $bgcolor) = @_ or return ''; -% my $format=qq{%b %o, %Y  %l:%M %P $el%b$eel$el %o,$eel$el %Y $eel$el %l$eel$el:$eel$el%M$eel$el %P $eel